2017 © Pedro Peláez
 

library phpunit-migration

Migrate your tests to newest PHPUnit version

image

webimpress/phpunit-migration

Migrate your tests to newest PHPUnit version

  • Thursday, May 10, 2018
  • by webimpress
  • Repository
  • 1 Watchers
  • 2 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Build Status Coverage Status, (*1)

PHPUnit migration tool

Migrate project to the newest version of PHPUnit., (*2)

[Work In Progress] Use it on the own risk :), (*3)

How to use the tool?

Clone the project:, (*4)

$ git clone https://github.com/webimpress/phpunit-migration.git

Go into the directory and install dependencies:, (*5)

$ cd phpunit-migration
$ composer install

To update your project to the newest version of PHPUnit go to your project directory and run:, (*6)

$ ../path/to/phpunit-migration/bin/phpunit-migration migrate

What the tool is changing?

  1. compose dependencies to the latest PHPUnit versions,
  2. \PHPUnit_Framework_TestCase to namespaced \PHPUnit\Framework\TestCase,
  3. setExpectedException to expectException*,
  4. setUp and tearDown to protected and correct case (setup => setUp etc.),
  5. FQCN in @cover tag (i.e. @covers MyClass to @covers \MyClass),
  6. assertInternalType and assertNotInternalType to more specific assertion method (PHPUnit 7.5+),
  7. getMock to getMockBuilder with other required function calls (PHPUnit 5.4+),
  8. getMockBuilder(...)->...->getMock() to createMock(...) if possible (PHPUnit 5.4+),
  9. assertEquals() and assertNotEquals() with $delta, $maxDepth, $canonicalize and $ignoreCase parameters to more specific assertion method (PHPUnit 7.5+),
  10. add void return type to the following methods: setUp(), tearDown(), setUpBeforeClass(), tearDownAfterClass(), assertPreConditions(), assertPostConditions(), onNotSuccessfulTest(\Throwable $th) (PHPUnit 8.0+),
  11. expectExceptionMessageRegExp to expectExceptionMessageMatches (PHPUnit 8.4+),
  12. use new (more readable) assertion names:
    • assertNotIsReadable replaced by assertIsNotReadable',
    • assertNotIsWritable replaced by assertIsNotWritable',
    • assertDirectoryNotExists replaced by assertDirectoryDoesNotExist',
    • assertDirectoryNotIsReadable replaced by assertDirectoryIsNotReadable',
    • assertDirectoryNotIsWritable replaced by assertDirectoryIsNotWritable',
    • assertFileNotExists replaced by assertFileDoesNotExist',
    • assertFileNotIsReadable replaced by assertFileIsNotReadable',
    • assertFileNotIsWritable replaced by assertFileIsNotWritable',
    • assertRegExp replaced by assertMatchesRegularExpression',
    • assertNotRegExp replaced by assertDoesNotMatchRegularExpression'. (PHPUnit 9.1+),
  13. TODO: getMockBuilder(...)->...->setMethods(...)->getMock() to createPartialMock(...) if possible (PHPUnit 5.5.3+),
  14. TODO: assertContains() and assertNotContains() on string haystack to more specific assertion method (PHPUnit 7.5+),
  15. TODO: $this->assert to self::assert.

What the tool is NOT doing?

  1. changing PHPUnit_Framework_Error_* classes
  2. probably other things I don't remember now ;-)

Note

Please remember it is developer tool and it should be used only as a helper to migrate your tests to newer version of PHPUnit. Always after migration run all your test to verify if applied changes are right and your tests are still working!, (*7)

The Versions

10/05 2018

dev-master

9999999-dev

Migrate your tests to newest PHPUnit version

  Sources   Download

BSD-2-Clause

The Requires