PHPUnit

PHPUnit 8

The PHPUnit development team is pleased to announce the immediate availability of PHPUnit 8. This release adds new features, changes and removes existing features, and fixes bugs.

A detailed list of changes is available here. More background on some of these changes is given here.

PHPUnit now requires PHP 7.2 (or newer)

Active support for PHP 7.1 ended on December 1, 2018. The only actively supported versions of PHP as of February 1, 2019 are PHP 7.2 and PHP 7.3.

PHPUnit now uses (more) PHP 7 syntax

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.

A lot of time and effort went into the development of PHPUnit 8 to make better use of language features such as strict interpretation of scalar type declarations, for instance, that were introduced in PHP 7.

Backward Incompatible Changes

Dependency Resolution and Result Caching

The optional resolution of test dependencies that was introduced in PHPUnit 7.2 is now enabled by default.

The optional caching of test results that was introduced in PHPUnit 7.3 is now enabled by default.

Return Type of Template Methods

The methods listed below now 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()

Your implementations of the methods listed above now must be declared void, too, otherwise you will get a compiler error.

Looking Forward

The following features have been deprecated in PHPUnit 8:

The features deprecated in PHPUnit 8 will be removed in PHPUnit 9.

Getting PHPUnit 8

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.

Supported Versions

Detailed information on supported versions of PHPUnit is available here. Below is a summary as of February 1, 2019:

  • PHPUnit 8 receives bug fixes until February 5, 2021
  • PHPUnit 7 receives bug fixes until February 7, 2020
  • PHPUnit 6 has reached its End of Life on February 1, 2019 and no longer receives bug fixes