Data provider methods should be static in PHPUnit11

Created on 21 July 2025, 6 days ago

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 🌱 [meta] Support PHPUnit 11 in Drupal 10 Postponed 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

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

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom jonathan1055

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024