PHPUnit 9

February 7, 2020

The PHPUnit development team announces the immediate availability of PHPUnit 9. 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.3 (or newer)

Active support for PHP 7.2 ended on November 30, 2019. The only actively supported versions of PHP as of February 7, 2020 are PHP 7.3 and PHP 7.4.

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 9 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

The following functionality was removed:

Annotation(s) for expecting exceptions

Assertions (and helper methods) that operate on (non-public) attributes

Optional parameters of assertEquals() and assertNotEquals()

and Optional parameters of assertContains() and assertNotContains()

and Optional parameters of assertFileEquals() etc.

etc. assertInternalType() and assertNotInternalType()

and assertArraySubset()

setUseErrorHandler()

expectExceptionMessageRegExp()

Support for doubling multiple interfaces

Support for using class name as CLI argument

Support for declaring more that one test case class in test source file

Looking Forward

The following features have been deprecated in PHPUnit 9:

expectException(PHPUnit\Framework\Error\*)

MockBuilder::setMethods()

Support for ClassName<*> as values for @covers and @uses annotations

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

Getting PHPUnit 9

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 7, 2020: