Problem/Motivation
TestCase::getAnnotations() method was removed in phpunit 9.5: https://github.com/sebastianbergmann/phpunit/commit/68582043e149039cfa35... called in DrupalStandardsListenerTrait::checkValidCoversForTest().
Steps to reproduce
- Update to phpunit 9.5: composer update "phpunit/phpunit ^9" --with-dependencies
- Run any test using phpunit: vendor/bin/phpunit -c core/phpunit.xml.dist core/modules/action/tests/src/Unit
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3186443-1.patch | 2.51 KB | tuutti |
Comments
Comment #2
tuutti commentedComment #3
longwaveThanks! Queued on PHP 7.3 as well, as we are also compatible with PHPUnit 8 (which is used on PHP 7.3 only now) and so need the tests to still run there as well.
Comment #4
marcelovaniFound the same issue today
Comment #5
marcelovaniThe patch worked fine, in the sense that it fixed the error message.
But it caused another issue:
FATAL Drupal\Tests\boxout\Functional\BoxoutTest: test runner returned a non-zero error code (2)
Steps to reproduce:
- Install Drupal 9
- Run tests without excluding deprecation i.e.
Pre-requisites: the test must contain a check for response code i.e. $this->assertResponse(200, 'Test response');
The results will report this deprecation:
Now, change $this->assertResponse() to $this->assertSession()->statusCodeEqual() and re-run the tests
The fatal error happens.
Comment #6
mondrakeBumping to critical since now the PHP 7.4 and 8 tests are all failing.
IMHO we should consider to set the PHPUnit constraint in composer.json to limit the upper version, PHPUnit are very aggressive in removing internal methods and we may end up with failing tests at any PHPUnit minor.
Comment #7
alexpott@mondrake I think this is fine. I don't think we should have upper constraints here - it'll just stop us from fixing things like this.
@marcelovani the other reported in #5 is because the test is using deprecated code. You could either disable deprecation testing or fix it.
Committed and pushed 754b8ffab2 to 9.2.x and adc897b798 to 9.1.x. Thanks!
Comment #10
heddnFor anyone facing this while core 9.1.1 isn't released... simply dropping back to phpunit 9.4.3 is sufficient to get tests running again.
composer require --dev phpunit/phpunit:9.4.3 --with-all-dependenciesComment #11
tyler36 commented@heddn That works.
Note: You have to be using
composer >= 2to use the--with-all-dependenciesswitchUpdate composer with the following:
composer selfupdate --2