Change record status: 
Project: 
Introduced in branch: 
8.8.x
Introduced in version: 
8.8.0
Description: 

Drupal 8.8.0 will require PHP 7, and will no longer support PHPUnit 4.x.; it will only use PHPUnit ^6.5 for testing.

As an effect of this,

  1. The drupal-phpunit-upgrade and drupal-phpunit-upgrade-check composer commands were no longer needed and have been removed.
  2. The methods getMock and setExpectedException, that provided a BC layer for test code to work on PHPUnit 4, are deprecated and should not be used any longer. They will be removed in Drupal 9. The backwards-compatibility layer method Drupal\Tests\PhpunitCompatibilityTrait::createMock was removed completely.
    • For getMock, replace with PHPUnit\Framework\TestCase::createMock() or getMockBuilder()
    • For setExpectedException, replace all calls with $this->expectException and $this->expectExceptionMessage.
  3. Usage of old style PHPUnit class names (e.g. \PHPUnit_Framework_AssertionFailedError), that is provided as a FC layer for PHPUnit 4 test code to work in PHPUnit 6, is now deprecated. Test developers should instead import the fully namespaced class from PHPUnit with

    use PHPUnit\Framework\AssertionFailedError;

    and then use [classname]::class to refer to the class in code

    $this->expectException(AssertionFailedError::class);

Impacts: 
Module developers
Site templates, recipes and distribution developers

Comments

mradcliffe’s picture

Note that the comment in Drupal\Tests\PhpunitCompatibilityTrait::getMock is incorrect. It suggests to use the Drupal\Tests\PhpunitCompatibilityTrait::createMock method which was removed in the commit related to this change record. This doesn't matter in practice except for the fact that the use statement for Drupal\Tests\PhpunitCompatibilityTrait should be removed as the entire file has been removed from Drupal 9.