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 Address phpunit tests now give warnings about non-static data providers

* PHPUnit\Event\Test\PhpunitErrorTriggered: 
The data provider specified for Drupal\Tests\address\Unit\Plugin\Validation\Constraint\CountryConstraintValidatorTest::testValidate is invalid
Data Provider method Drupal\Tests\address\Unit\Plugin\Validation\Constraint\CountryConstraintValidatorTest::providerTestValidate() is not static

and

* PHPUnit\Event\Test\PhpunitErrorTriggered:
The data provider specified for Drupal\Tests\address\Kernel\Formatter\AddressPlainFormatterTest::testRender is invalid
Data Provider method Drupal\Tests\address\Kernel\Formatter\AddressPlainFormatterTest::renderDataProvider() is not static

We also get a third error

* PHPUnit\Event\TestRunner\WarningTriggered: No tests found in class "Drupal\Tests\address\Unit\Plugin\Validation\Constraint\CountryConstraintValidatorTest"

Steps to reproduce

I do not have access to view the pipeline logs (which is odd, as I can on most other projects). However, I get these errors and warnings when Address is used in 3rd-party module testing. See this Scheduler job

This warning is also show in the PHPStan analysis

Proposed resolution

MR to follow

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

2.1

Component

Code

Created by

🇬🇧United Kingdom jonathan1055

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

Comments & Activities

  • Issue created by @jonathan1055
  • 🇬🇧United Kingdom jonathan1055

    It seems that this has already been fixed in 📌 Fix cspell and phpstan builds Active on the 2.1.x branch. If I was able to view the pipeline logs I could have discovered that.

    In Scheduler, the Address module is brought in as a 3rd-party dependency from Commerce, and this currently only uses Address 2.0.4 released May 2025, but this fix is not included in that. Is there a plan to back-port the fix to 2.0.x ?

Production build 0.71.5 2024