The PHPUnit development team is pleased to announce the immediate availability of PHPUnit 7. This release adds new features, changes and removes existing features, and fixes bugs.
A detailed list of changes is available here.
Active support for PHP 7.0 ended on December 3, 2017. The only actively supported versions of PHP as of February 2, 2018 are PHP 7.1 and PHP 7.2.
The first lines of code for PHPUnit were written back when PHP 4 was the "latest and greatest". In order to keep PHPUnit compatible with new versions of PHP and to make new features possible, the codebase of PHPUnit needs constant modernization.
It has taken Sebastian Bergmann thousands of hours to develop, test, and support PHPUnit.
Perhaps now is the time to contribute to the development of PHPUnit or sponsor Sebastian's work.
A lot of time and effort went into the development of PHPUnit 7 to make better use of syntax features such as scalar type declarations and return type declarations, for instance, that were introduced in PHP 7. And quite a few methods that can raise exceptions were missing @throws
annotations, there were now added to the documentation of those methods.
While the aforementioned changes make PHPUnit's code easier to read and more robust to work on, they come at the price of backward compatibility breaks.
PHPUnit\Framework\TestListener
, then you may need to update the signatures of your methods.PHPUnit\Framework\TestCase
, then you may need to update the signatures of your methods.PHPUnit\Framework\BaseTestListener
class has been removed, it was deprecated since PHPUnit 6.4. Please use the PHPUnit\Framework\TestListenerDefaultImplementation
instead.@scenario
annotation is no longer an alias for @test
, it no longer has any effect.PHPUnit\Framework\TestCase::prepareTemplate()
template method has been removed.The following methods do not have a return value and should therefore have a void
return type declaration:
PHPUnit\Framework\TestCase::setUpBeforeClass()
PHPUnit\Framework\TestCase::setUp()
PHPUnit\Framework\TestCase::assertPreConditions()
PHPUnit\Framework\TestCase::assertPostConditions()
PHPUnit\Framework\TestCase::tearDown()
PHPUnit\Framework\TestCase::tearDownAfterClass()
PHPUnit\Framework\TestCase::onNotSuccessfulTest()
These methods will have a void
return type declaration in PHPUnit 8. Please declare your methods that overwrite the above mentioned methods void
now so you are not affected by this backward compatibility break.
The documentation for PHPUnit has been migrated from DocBook to reStructuredText and is now hosted on docs.phpunit.de
. Details on the new locations can be found here.
We distribute a PHP Archive (PHAR) that contains everything you need in order to use PHPUnit. Alternatively, you may use Composer to download and install PHPUnit as well as its dependencies.
Here is a tutorial that gets you started.
Detailed information on supported versions of PHPUnit is available here. Below is a summary as of February 2, 2018: