By amateescu on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.8.x
Introduced in version:
8.8.0
Issue links:
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,
- The
drupal-phpunit-upgradeanddrupal-phpunit-upgrade-checkcomposer commands were no longer needed and have been removed. - The methods
getMockandsetExpectedException, 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 methodDrupal\Tests\PhpunitCompatibilityTrait::createMockwas removed completely.- For
getMock, replace withPHPUnit\Framework\TestCase::createMock()orgetMockBuilder() - For
setExpectedException, replace all calls with$this->expectExceptionand$this->expectExceptionMessage.
- For
- 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 withuse PHPUnit\Framework\AssertionFailedError;and then use
[classname]::classto refer to the class in code$this->expectException(AssertionFailedError::class);
Impacts:
Module developers
Site templates, recipes and distribution developers
Comments
.
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.