Skip to content

Remove the deprecated WP_UnitTestCase_Base::checkRequirements() - #13599

Closed
CodeSawMir wants to merge 1 commit into
WordPress:trunkfrom
CodeSawMir:remove-deprecated-checkrequirements
Closed

CodeSawMir wants to merge 1 commit into
WordPress:trunkfrom
CodeSawMir:remove-deprecated-checkrequirements

Conversation

@CodeSawMir

@CodeSawMir CodeSawMir commented Sep 18, 2026

Copy link
Copy Markdown

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() is private as of PHPUnit 7.0, so such a call
raises Error: Call to private method ... from scope .... The guard meant to
prevent it is ineffective — is_callable() takes bool $syntax_only as its
second parameter, so is_callable( 'PHPUnit\Framework\TestCase', 'checkRequirements' )
returns true on every version.

The override is also unreachable from PHPUnit itself: private methods don't
participate in override dispatch, so $this->checkRequirements() inside
TestCase binds to that class's own private method. No behavior change, no
test failures before or after.

A standalone reproduction script (no PHPUnit required) is attached to the Trac
ticket.

…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.
@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown

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 props-bot label.

Unlinked Accounts

The 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:

Props mukesh27.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 mukeshpanchal27 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing in core calls it.

@CodeSawMir

Copy link
Copy Markdown
Author

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).

wporg-sync pushed a commit that referenced this pull request Sep 18, 2026
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
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 63760
GitHub commit: 74bb933

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Sep 18, 2026
@CodeSawMir
CodeSawMir deleted the remove-deprecated-checkrequirements branch September 18, 2026 14:06
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Sep 18, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants