Remove the deprecated WP_UnitTestCase_Base::checkRequirements() - #13599
CodeSawMir wants to merge 1 commit into
Conversation
…equirements()`. This method was hard-deprecated in [51605] and retained only as a backward compatibility layer for external test suites still calling `parent::checkRequirements()`. That compatibility layer has never functioned. `TestCase::checkRequirements()` became `private` in PHPUnit 7.0, so a subclass calling it raises `Error: Call to private method ... from scope ...`. The guard added to prevent exactly that is itself ineffective: `is_callable()` takes `bool $syntax_only` as its second parameter, so passing `'checkRequirements'` casts to `true` and the check only confirms that the first argument looks like a callable. It returns `true` on every PHPUnit version. The method is also unreachable from PHPUnit itself. Private methods do not take part in override dispatch, so `$this->checkRequirements()` inside `TestCase` binds to that class's own private method rather than the override here. This is why the dead code has never surfaced as a test failure. Follow-up to [51605]. See #62004.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @CodeSawMir. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved issues were identified.
Pull request overview
Removes the obsolete, non-functional checkRequirements() compatibility method.
Changes:
- Deletes the deprecated override and outdated guard.
- Preserves PHPUnit’s native requirement handling.
File summaries
| File | Description |
|---|---|
tests/phpunit/includes/abstract-testcase.php |
Removes the deprecated checkRequirements() override. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mukeshpanchal27
left a comment
There was a problem hiding this comment.
Nothing in core calls it.
|
Thanks! Worth noting the guard is also a no-op — is_callable()'s second parameter is bool $syntax_only, so is_callable( 'PHPUnit\Framework\TestCase', 'checkRequirements' ) returns true on every version (it returns true for a nonexistent class too). |
The method was hard-deprecated in WordPress 5.9 and retained only as a backward compatibility layer for external test suites that may have been still calling `parent::checkRequirements()` on PHPUnit 5/6. As the method has not been functional since `TestCase::checkRequirements()` became `private` in PHPUnit 7.0, it should be safe to remove at this point. Reference: [https://make.wordpress.org/core/handbook/references/phpunit-compatibility-and-wordpress-versions/ PHPUnit Compatibility and WordPress Versions]. Developed in #13599. Follow-up to r51605. Props codesawmir, mukesh27. Fixes #66135. git-svn-id: https://develop.svn.wordpress.org/trunk@63760 602fd350-edb4-49c9-b593-d223f7449a82
The method was hard-deprecated in WordPress 5.9 and retained only as a backward compatibility layer for external test suites that may have been still calling `parent::checkRequirements()` on PHPUnit 5/6. As the method has not been functional since `TestCase::checkRequirements()` became `private` in PHPUnit 7.0, it should be safe to remove at this point. Reference: [https://make.wordpress.org/core/handbook/references/phpunit-compatibility-and-wordpress-versions/ PHPUnit Compatibility and WordPress Versions]. Developed in WordPress/wordpress-develop#13599. Follow-up to r51605. Props codesawmir, mukesh27. Fixes #66135. Built from https://develop.svn.wordpress.org/trunk@63760 git-svn-id: http://core.svn.wordpress.org/trunk@62932 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Trac ticket: https://core.trac.wordpress.org/ticket/66135
Description
Removes
WP_UnitTestCase_Base::checkRequirements(), hard-deprecated in [51605]and non-functional on every supported PHPUnit version.
The method was kept as a BC layer for external suites calling
parent::checkRequirements(), but that layer has never worked:TestCase::checkRequirements()isprivateas of PHPUnit 7.0, so such a callraises
Error: Call to private method ... from scope .... The guard meant toprevent it is ineffective —
is_callable()takesbool $syntax_onlyas itssecond parameter, so
is_callable( 'PHPUnit\Framework\TestCase', 'checkRequirements' )returns
trueon every version.The override is also unreachable from PHPUnit itself: private methods don't
participate in override dispatch, so
$this->checkRequirements()insideTestCasebinds to that class's own private method. No behavior change, notest failures before or after.
A standalone reproduction script (no PHPUnit required) is attached to the Trac
ticket.