Problem/Motivation

The Purge module's test suite uses patterns that are deprecated in PHPUnit 10/11 and removed in PHPUnit 12. This will cause test failures when Drupal core requires PHPUnit 12.

Steps to reproduce

Proposed resolution

Modernize all unit tests for PHPUnit 12 compatibility, eliminating all deprecation warnings.

Annotations → Attributes

  • @dataProvider#[DataProvider('methodName')]
  • @group#[Group('name')]
  • @coversDefaultClass#[CoversClass(ClassName::class)] or #[CoversTrait(TraitName::class)]
  • Remove method-level @covers ::methodName (not supported as attributes)

Data Providers

  • Change from protected function to public static function

Mock Methods

  • ->will($this->returnValue($x))->willReturn($x)
  • ->will($this->returnValueMap([...]))->willReturnMap([...])

Trait Mocking

  • Replace deprecated getMockForTrait() with anonymous class pattern

Interface Mocking

  • Fix incorrect getMockForAbstractClass() on interface → createMock()

Code Quality

  • Add docblocks to all test classes and methods
  • Fix indentation inconsistencies

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork purge-3587982

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

kim.pepper created an issue. See original summary.

kim.pepper’s picture

Issue summary: View changes
kim.pepper’s picture

Status: Active » Needs review

This is ready for review. Disclaimer: I used Claude Code to help automate a lot of bulk changes in this MR.

andypost’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +PHPUnit 12

Looks ready to go! Thank you

japerry’s picture

Status: Reviewed & tested by the community » Needs work
japerry’s picture

Status: Needs work » Needs review

Updated the MR to add the group tags missing.

japerry’s picture

Status: Needs review » Fixed

Thanks @kim.pepper for this. Made a few changes and committed. We'll follow up anything in #3590026: Drupal 12 + PHP Compatibility

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • japerry committed 41799d62 on 8.x-3.x authored by kim.pepper
    fix: #3587982 Modernize unit tests for PHPUnit 12 compatibility
    
kim.pepper’s picture

Nice. Thank you!

Status: Fixed » Closed (fixed)

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