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 static

We 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

Command icon 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

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

Issue summary: View changes
Status: Active » Needs review

The 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.

jonathan1055’s picture

This correction has also removed the warning No tests found in class "Drupal\Tests\token\Kernel\LanguageTest which means that tests in this class are now being run (they were not, before). We get the extra line

Drupal\Tests\token\Kernel\LanguageTest                          30 passed

I'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.

berdir made their first commit to this issue’s fork.

  • berdir committed 3ea0c877 on 8.x-1.x authored by jonathan1055
    Issue #3537090 by jonathan1055: Data provider methods should be static...
berdir’s picture

Status: Needs review » Fixed

Thanks, merged.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.