Repository navigation
Tests: Make data providers in tests/phpunit/tests/blocks/ public and static - #15180
rejaulalomkhan wants to merge 2 commits into
Conversation
…static. Declares data provider methods as \public static\ across \editor.php\, \ egister.php\, \ ender.php\, \supportedStyles.php\, \wpBlock.php\, \wpBlockParser.php\, and \wpBlockType.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 changes look correct. I checked that no static provider or helper uses This PR needs a rebase. Commit f2d0059 (r65006) already made the 5 providers in |
lancewillett
left a comment
There was a problem hiding this comment.
I agree with @mukeshpanchal27: please refresh this against trunk and drop tests/phpunit/tests/blocks/register.php. Those five provider conversions already landed in r65006 from #14652.
I tested the other six files locally after excluding that duplicate change. The static fixture callbacks work, and randomized single-site/multisite runs passed with the same existing PHPUnit warnings as unchanged trunk. No additional code changes found necessary; please refresh so the PR diff applies cleanly for SVN.
AI review · gpt-6
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the PHPUnit 10+ data-provider compatibility updates.
No open issues 🎉
What changed in this PR
Updates block-test data providers to meet PHPUnit 10+ static-method requirements. This consolidates the directory-level work for Trac #66211 and supersedes the registration-only PR #14954.
Changes:
- Declares 13 data providers across seven test files as
public static. - Converts rendering and parser fixture helpers to static methods and replaces instance callbacks with class callbacks.
- Leaves test datasets and fixture expectations unchanged.
| File | Description |
|---|---|
tests/phpunit/tests/blocks/wpBlockType.php |
Makes the block-version provider static. |
tests/phpunit/tests/blocks/wpBlockParser.php |
Makes the parser provider and fixture helpers static; updates callbacks. |
tests/phpunit/tests/blocks/wpBlock.php |
Makes rendering-assets and block-support providers static. |
tests/phpunit/tests/blocks/supportedStyles.php |
Makes the wrapper-attribute provider static. |
tests/phpunit/tests/blocks/render.php |
Makes the rendering provider and fixture helpers static; updates callbacks. |
tests/phpunit/tests/blocks/register.php |
Makes five block-registration providers static. |
tests/phpunit/tests/blocks/editor.php |
Makes media-setting and REST-preload providers static. |
Review effort: Balanced
|
@mukeshpanchal27 @lancewillett Merged trunk (f36c601). |
lancewillett
left a comment
There was a problem hiding this comment.
The refresh removes already-landed conversions. Remaining providers and fixture callbacks are consistently static, with datasets and assertions preserved.
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 #15180 landed in https://core.trac.wordpress.org/changeset/65128 |
Description
Makes the remaining data providers in
tests/phpunit/tests/blocks/public static. PHPUnit 10+ requires static data providers, and none of these use instance state.The fixture helpers in
render.phpandwpBlockParser.phpthat these providers call are made static too, and theirarray( $this, ... )callbacks becomearray( __CLASS__, ... ).Files and providers:
editor.php:data_get_default_block_editor_settings_auto_attach_media_enabled(),data_block_editor_rest_api_preload_adds_missing_leading_slash()render.php:data_do_block_test_filenames()supportedStyles.php:data_get_block_wrapper_attributes_merge_or_override()wpBlock.php:data_provider_test_render_enqueues_scripts_and_styles(),data_block_has_support_string()wpBlockParser.php:data_parsing_test_filenames()wpBlockType.php:data_block_version()The providers in
register.phpwere already made static in r65006, so that file is no longer part of this PR. This supersedes #14954.Testing
On my machine (Windows, PHP 8.2) the group runs 718 tests (717 on multisite). Three tests fail with and without this PR (
Tests_Get_Block_Asset_Url::test_core_block,Tests_Blocks_GetHookedBlocks::test_loading_pattern_with_hooked_blocks,Tests_Blocks_WpBlockMetadataRegistry::test_get_collection_block_metadata_files); they are path-related and not in the changed files. 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: Finding the non-static providers and converting them, then merging trunk after r65006 and running the test suites. I reviewed every line and take responsibility for the change.