Shift with red gradient lettering
Loading navigation...

PHPUnit 9 Shift

The PHPUnit 9 Shift automates the upgrade of your PHPUnit 8 test suite to PHPUnit 9. Using the PHPUnit 9 Shift to automatically upgrade your PHPUnit test suite has an estimated time savings of 1 hour.

Screenshot of a pull request with automated changes from the PHPUnit 9 Shift

Requirements

  • Running PHP 7.3 or higher.
  • Previously running PHPUnit 8 or higher.
  • Test classes within the tests folder.

Automated Changes

  • Adding return types to core TestCase methods.
  • Updating phpunit/phpunit composer dependency to ^9.0.
  • Converting uses of the removed assertInternalType to its type specific equivalent.
  • Detecting uses of the removed assertContains and converting to the string assertion when appropriate.
  • Automating the changes for renamed or methods such as expectExceptionMessageRegExp and assertEquals.
  • Detecting uses of removed annotations and assertions, such as @see Classname::<*> and assertAttribute*.
  • Modernizing PHP syntax, such as short arrays.

Manual Changes

While the PHPUnit 9 Shift addresses most of the backward incompatible changes, you may wish to review the release notes for additional details.