Release Announcement for PHPUnit 4.0.0

Sebastian Bergmann edited this page Feb 9, 2015 · 18 revisions

The PHPUnit development team announces the immediate availability of PHPUnit 4.0.0. This release adds new features, removes existing features, and fixes bugs. A detailed list of changes is available here.

New Release Process

PHPUnit 4.0.0 is the first version of PHPUnit that follows our new release process. It is also the first release of PHPUnit to ship new features since September of 2012 when PHPUnit 3.7 was released. Our goal with the new release process is to deliver new features into the hands of our users every two months.

New Features

PHPUnit 4.0 introduces many new features. Here is a list of the highlights:

Backwards Compatibility Issues

  • 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.

Caveats

  • The simplified stubbing of return values using the new willReturn*() syntax does not work for classes that have a method named method

Obtaining PHPUnit 4.0

We distribute a PHP Archive (PHAR) that contains everything you need in order to use PHPUnit. Simply download it from here, make it executable, and put it into your $PATH, for instance.

Alternatively, you may use Composer or the PEAR Installer to download and install PHPUnit as well as its dependencies.

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.

Requirements

PHPUnit 4.0 requires PHP 5.3.3; using the latest version of PHP is highly recommended. The documentation has a detailed list of the PHP extensions that are required to use PHPUnit.