Appendix D. Upgrading

Upgrading from PHPUnit 3.7 to PHPUnit 4.0

  • The limited support for stubbing and mocking static methods that was introduced in PHPUnit 3.5 has been removed. This feature only worked when the stubbed or mocked static method was invoked from another method of the same class. We believe that the limited use of this feature did not justify the increased complexity in the test doubles code generator it incurred. We apologize for any inconvenience this removal may cause and encourage refactoring the code under test to not require this feature for testing.

  • The addRiskyTest() was added to the PHPUnit_Framework_TestListener interface. Classes that implement this interface have to implement this new method. This is the reason why PHPStorm 7 is not compatible with PHPUnit 4, for instance.

  • The fixes for #552, #573, and #582 required a change to how relative paths are resolved for PHPUnit's XML configuration file. All relative paths in a configuration file are now resolved relative to that configuration file. When upgrading, you may need to update relative paths for the following configurations testSuiteLoaderFile, printerFile, testsuites/file, and testsuites/exclude.

  • The numeric comparator is no longer invoked when provided with two strings.

Please note that starting with PHPUnit 4.0.0 the PEAR package of PHPUnit is merely a distribution mechanism for the PHP Archive (PHAR) and that many of PHPUnit's dependencies will no longer be released individually via PEAR. We will eventually stop making releases of PHPUnit available via PEAR altogether.

Please note that using the PEAR installer to update from PHPUnit 3.7 to PHPUnit 4.0 will leave stale source files from previous versions of PHPUnit's dependencies (PHP_CodeCoverage, PHPUnit_MockObject, ...) behind in your PHP environment's PEAR directory. It is advised to uninstall the respective PEAR packages.

Upgrading from PHPUnit 4.0 to PHPUnit 4.1

Upgrading from PHPUnit 4.1 to PHPUnit 4.2