Problem/Motivation
Spin-off from #3063887: Support PHPUnit 8 in Drupal 9, drop support for PHPUnit 7.
PHPUnit 8 is changing the signature of the main test methods that test classes extend - above all setUp
and tearDown
, adding a void
return typehint.
As per #3063887-75: Support PHPUnit 8 in Drupal 9, drop support for PHPUnit 7, in this issue we change the signatures of the methods in concrete Drupal test code according to PHPUnit 8.
Proposed resolution
@catch and I agreed that this is a good approach for addressing this compatibility issue so that we're ready by Drupal 10. Thanks!
Change all the implementations of
setUp()
tearDown()
setUpBeforeClass()
assertPostConditions()
in concrete test classes to have a void
return typehint.
We will then add a deprecation to inform developers of this change in #3111044: Deprecate setUp/tearDown concrete test methods that do not specify void return type
We cannot change abstract base test classes without breaking backward compatibility, so that will be done in a follow-up.
Remaining tasks
Patch.
User interface changes
API changes
Data model changes
Release notes snippet
Overridden test methods should have void return type hints added, see the change record at https://www.drupal.org/node/3114724 for more details.