Repository navigation
Tests: Make data providers in tests/phpunit/tests/pluggable/ public and static - #15176
rejaulalomkhan wants to merge 2 commits into
Conversation
…nd static. Declares data provider methods as \public static\ in \wpRand.php\. See #66211.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
|
Thanks, @rejaulalomkhan! The two changes in This PR misses one provider in this directory. One test also calls it directly, at about line 60: $defined = wp_list_pluck( $this->get_defined_pluggable_functions(), 0 );This call still works after the change. For consistency, please update it to |
lancewillett
left a comment
There was a problem hiding this comment.
I agree with @mukeshpanchal27: please include get_defined_pluggable_functions() in tests/phpunit/tests/pluggable/signatures.php in this directory-wide conversion. It is used as a @dataProvider and remains non-static. Make it public static and update its direct call in test_all_pluggable_functions_exist() to self::get_defined_pluggable_functions(). The separate get_pluggable_function_signatures() helper can stay as it is. Please include the existing signature tests in verification. The two wpRand.php conversions look correct.
AI review · gpt-6
There was a problem hiding this comment.
🟡 Changes recommended
The directory-wide migration claim is inaccurate because signatures.php still has a non-static data provider, so either that provider must be migrated or the PR description narrowed.
1 open issue
What changed in this PR
This PR updates the two wp_rand() data providers to meet PHPUnit’s static-provider requirement without changing their datasets or test assertions.
Changes:
- Declares both data provider methods in
wpRand.phpaspublic static. - Leaves the existing test cases and fixtures unchanged.
| File | Description |
|---|---|
tests/phpunit/tests/pluggable/wpRand.php |
Makes both data providers static for PHPUnit compatibility. |
Review effort: Balanced
| * @return array | ||
| */ | ||
| public function data_wp_rand_should_return_zero_when_min_and_max_are_zero() { | ||
| public static function data_wp_rand_should_return_zero_when_min_and_max_are_zero() { |
Follow-up to the data provider changes in the pluggable directory. See #66211.
|
@mukeshpanchal27 @lancewillett |
lancewillett
left a comment
There was a problem hiding this comment.
The missing signatures provider is now static and its direct caller uses self::. This addresses the earlier request.
Static checks passed. The affected classes passed together in randomized single-site and multisite runs: 408 tests and 1,383 assertions in each mode.
AI review · gpt-6
Convert the remaining providers and fixture callbacks to static methods. Preserve datasets, expectations, and the already-landed provider cleanup. Developed in: #14970, #15176, #15180 Props rejaulalomkhan, shailu25, mukesh27. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@65128 602fd350-edb4-49c9-b593-d223f7449a82
Convert the remaining providers and fixture callbacks to static methods. Preserve datasets, expectations, and the already-landed provider cleanup. Developed in: WordPress/wordpress-develop#14970, WordPress/wordpress-develop#15176, WordPress/wordpress-develop#15180 Props rejaulalomkhan, shailu25, mukesh27. See #66211. Built from https://develop.svn.wordpress.org/trunk@65128 git-svn-id: http://core.svn.wordpress.org/trunk@64277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
|
PR #15176 landed in https://core.trac.wordpress.org/changeset/65128 |

Description
Makes the data providers in
tests/phpunit/tests/pluggable/public static. PHPUnit 10+ requires static data providers, and none of these use instance state.wpRand.php:data_wp_rand_should_return_a_non_negative_integer(),data_wp_rand_should_return_zero_when_min_and_max_are_zero()signatures.php:get_defined_pluggable_functions(). Its direct call intest_all_pluggable_functions_exist()now usesself::. Theget_pluggable_function_signatures()helper is not a provider and is left as is.Testing
All pass (324 tests in the group, 66 of them signature tests); PHPCS: no errors.
Trac ticket: https://core.trac.wordpress.org/ticket/66211
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
Use of AI Tools
AI assistance: Yes
Tool(s): Google Antigravity (original change), Claude Code (review follow-up)
Model(s): Gemini 2.5 Pro, Claude Opus 5.5
Used for: Converting the providers, adding the missed
signatures.phpprovider and running the tests. I reviewed every line and take responsibility for the change.