Problem/Motivation

We need to ensure all PHPUnit tests are compatible with PHPUnit 10 by updating all dataProvider methods to be static. This is a mandatory requirement for running tests in Drupal 11, as non-static dataProvider methods will cause PHPUnit deprecation warnings and potential test failures.

Change Record: Changes required for PHPUnit 10 compatibility
Issue: #3353210: [PHPUnit 10] @dataProvider methods must be declared static and public

Steps to reproduce

Run the PHPUnit tests on Drupal 11 and you would see test failure with showing deprecation warnings.

Proposed resolution

  • Locate all dataProvider methods within tests directory. A dataProvider method is usually annotated with @dataProvider in the test methods.
  • Convert each dataProvider

Issue fork scheduler-3463141

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

vishalkhode created an issue. See original summary.

vishalkhode’s picture

Issue summary: View changes

vishalkhode’s picture

Status: Active » Needs review

Cherry-picked @chandu7929 commit from #3434325: Drupal 11 compatibility fixes [2.x].

vishalkhode’s picture

Assigned: vishalkhode » Unassigned
deepakkm’s picture

Status: Needs review » Reviewed & tested by the community

Verified this and its working fine

vishalkhode’s picture

Hi @jonathan1055
Can you review/merge the changes as I've rebased now with #3463494: Gitlab PHPunit jobs at D11 need compatible test dependencies.
Thanks.

jonathan1055’s picture

Status: Reviewed & tested by the community » Fixed
Related issues: -#3434325: Drupal 11 compatibility fixes [2.x]

Previous tests had

Data Provider method Drupal\Tests\scheduler\Functional\SchedulerDefaultTimeTest::dataStandardEntityTypes() is not static

All of these errors have been removed with the MR

Accesing $this in data providers is no longer allowed, so these have been replaced with self::dataStandardEntityTypes(). The only place where hardcoded entity types have been used is in the definition of the two functions. There is no simple way round this, so we accept that this is duplicated hard-coding.

Thanks. Merged and fixed

jonathan1055’s picture

Status: Reviewed & tested by the community » Fixed
Related issues: -#3434325: Drupal 11 compatibility fixes [2.x]

Something odd happened. The status and related issue changes in #9 got lost, so re-doing.

jonathan1055’s picture

The credit I gave in #9 also got lost, so re-doing that too.

Status: Fixed » Closed (fixed)

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

jonathan1055’s picture