Opened 10 months ago
Closed 10 months ago
#60551 closed defect (bug) (duplicate)
WordPress test lib isn't compatible with latest phpunit
Reported by: | jujuguru | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.4.3 |
Component: | Build/Test Tools | Keywords: | |
Focuses: | Cc: |
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.
Hi there and welcome to WordPress Trac!
We're already tracking this in #59486, would you mind sharing your experience & workaround there? Thanks!