Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294618

Add return typehints to setUp/tearDown test methods

$
0
0

Problem/Motivation

Spin-off from #3063887: Support PHPUnit 8 in Drupal 9, drop support for PHPUnit 7.

In order to make the test codebase forward compatible with PHPUnit 8, the big problem is that 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.

In this issue we explore the option 1 of #3063887: Support PHPUnit 8 in Drupal 9, drop support for PHPUnit 7, i.e. Change the signatures of the methods in Drupal test code according to PHPUnit 8.

While this is not a problem for Drupal 9 core, that supports PHP 7.3+, this will have the impact of forcing testing for contrib/custom modules only on PHP 7.1+ (the minimum that allows specifying a void return typehint to methods).

Setting to critical since per @xjm at #3063887-39: Support PHPUnit 8 in Drupal 9, drop support for PHPUnit 7

If anything I'd want to make the break in 9.0 rather than 9.1 because that's a massive change.

Proposed resolution

Change all the implementations of

  • setUp()
  • tearDown()
  • setUpBeforeClass()
  • assertPostConditions()

in test classes to have a void return typehint.

Remaining tasks

Discuss.
Patch.

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 294618

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>