Problem/Motivation
Starting with Drupal Core 11.2 the PHPUnit version moved from 10 to 11 which has introduced some changes in test discovery and some deprecations (see #3418267: Support PHPUnit 11 in Drupal 11 and the child issue).
Two of the Token phpunit tests now give warnings about non-static data providers
* PHPUnit\Event\Test\PhpunitErrorTriggered:
The data provider specified for Drupal\Tests\token\Kernel\LanguageTest::testLanguageTokenReplacement is invalid
Data Provider method Drupal\Tests\token\Kernel\LanguageTest::languageTokenReplacementDataProvider() is not static
and
* PHPUnit\Event\Test\PhpunitErrorTriggered:
The data provider specified for Drupal\Tests\token\Kernel\LanguageTest::testCurrentPageLanguageTokenReplacement is invalid
Data Provider method Drupal\Tests\token\Kernel\LanguageTest::currentPageLanguageTokenReplacementDataProvider() is not staticWe also get a third error
* PHPUnit\Event\TestRunner\WarningTriggered: No tests found in class "Drupal\Tests\token\Kernel\LanguageTest".
Steps to reproduce
See recent scheduled pipeline
https://git.drupalcode.org/project/token/-/jobs/5949245#L64
This warning is also show in the PHPStan analysis
https://git.drupalcode.org/project/token/-/jobs/5949229#L101
Proposed resolution
Whilst these are only warnings, and not the cause of the test failures, they produce extra noise in the logs, not only of this module but in 3rd-party projects which use Token as a test dependency. It should be easy enough to fix and remove the warnings.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork token-3537090
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
jonathan1055 commentedThe warnings in PHPUnit no longer show
https://git.drupalcode.org/issue/token-3537090/-/jobs/5958549#L59
The phpunit errors are for other exitsing problems. The tests still pass green in Previous Minor (11.1) and Previous Major (10.5)
and the PHPStan mesages are also fixed
https://git.drupalcode.org/issue/token-3537090/-/jobs/5958544
This is ready for review.
Comment #4
jonathan1055 commentedThis correction has also removed the warning
No tests found in class "Drupal\Tests\token\Kernel\LanguageTestwhich means that tests in this class are now being run (they were not, before). We get the extra lineI've compared the logs before and after, and all other test results are the same.
So this is not just about fixing the warning, but also it restores test coverage for the LanguageTest.
Comment #7
berdirThanks, merged.