Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#60551 closed defect (bug) (duplicate)

WordPress test lib isn't compatible with latest phpunit

Reported by: jujuguru Owned by:
Priority: normal Milestone:
Component: Build/Test Tools Version: 6.4.3
Severity: normal Keywords:
Cc: Focuses:

Description

Current setup:
PHP version 8.2.15
WordPress version 6.4.3
PHPUnit version 11.0.3

Issue:
Trying to get unit testing for plugin development running but there is a call to a deprecated/no-longer present method the following file:

/tmp/wordpress-tests-lib/includes/abstract-testcase.php

Error: Call to undefined method PHPUnit\Util\Test::parseTestMethodAnnotations()

/tmp/wordpress-tests-lib/includes/abstract-testcase.php:546
/tmp/wordpress-tests-lib/includes/abstract-testcase.php:137
/var/www/html/wp-content/plugins/solomons-services/vendor/yoast/phpunit-polyfills/src/TestCases/TestCasePHPUnitGte8.php:60

What I discovered
Strictly this a breaking change in the PHPUnit codebase implied by the class annotation:

@internal This class is not covered by the backward compatibility promise for PHPUnit.

The method ​parseTestMethodAnnotations() was present upto and including 9.6.16 of PHPUnit however the file underwent a massive change and it's ​not been present since 10.0.0.

Workaround
Comment out the call to PHPUnit\Util\Test::parseTestMethodAnnotations() in abstact-testcase.php and the tests will run with a deprecation warning related to metadata and annotations but that doesn't affect this issue. I don't at this stage know if there's any other side effects as a result of this workaround.

Change History (1)

#1 @swissspidy
3 years ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Severity major → normal
  • Status new → closed

Hi there and welcome to WordPress Trac!

We're already tracking this in #59486, would you mind sharing your experience & workaround there? Thanks!

Note: See TracTickets for help on using tickets.