Skip to content

Tests: Make data providers in tests/phpunit/tests/blocks/ public and static - #15180

Closed
rejaulalomkhan wants to merge 2 commits into
WordPress:trunkfrom
rejaulalomkhan:tests/66211-static-dp-blocks-dir
Closed

rejaulalomkhan wants to merge 2 commits into
WordPress:trunkfrom
rejaulalomkhan:tests/66211-static-dp-blocks-dir

Conversation

@rejaulalomkhan

@rejaulalomkhan rejaulalomkhan commented Oct 29, 2026 •

Copy link
Copy Markdown

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.php and wpBlockParser.php that these providers call are made static too, and their array( $this, ... ) callbacks become array( __CLASS__, ... ).

Files and providers:

  1. editor.php: data_get_default_block_editor_settings_auto_attach_media_enabled(), data_block_editor_rest_api_preload_adds_missing_leading_slash()
  2. render.php: data_do_block_test_filenames()
  3. supportedStyles.php: data_get_block_wrapper_attributes_merge_or_override()
  4. wpBlock.php: data_provider_test_render_enqueues_scripts_and_styles(), data_block_has_support_string()
  5. wpBlockParser.php: data_parsing_test_filenames()
  6. wpBlockType.php: data_block_version()

The providers in register.php were already made static in r65006, so that file is no longer part of this PR. This supersedes #14954.

Testing

vendor/bin/phpunit --group blocks
vendor/bin/phpunit -c tests/phpunit/multisite.xml --group blocks
vendor/bin/phpunit --group blocks --order-by=random --random-order-seed=12345
vendor/bin/phpcs tests/phpunit/tests/blocks/

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.

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

github-actions Bot commented Oct 29, 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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props rejaulalomkhan, mukesh27, lancewillett.

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@mukeshpanchal27

Copy link
Copy Markdown
Member

Thanks, @rejaulalomkhan! The changes look correct. I checked that no static provider or helper uses $this. The switch from array( $this, ... ) to array( __CLASS__, ... ) for the fixture callbacks also works, because the callbacks still run inside the class.

This PR needs a rebase. Commit f2d0059 (r65006) already made the 5 providers in tests/phpunit/tests/blocks/register.php static, so that file now conflicts. Please rebase on trunk and drop the register.php changes. The other 6 files apply cleanly.

@mukeshpanchal27 mukeshpanchal27 Oct 29, 2026 •

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.

See my comment above

@lancewillett lancewillett 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.

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

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

@rejaulalomkhan

Copy link
Copy Markdown
Author

@mukeshpanchal27 @lancewillett Merged trunk (f36c601). register.php dropped out of the diff since r65006 made the same change, so the PR now covers the other six files. I updated the description to match.

@lancewillett lancewillett 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.

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

wporg-sync pushed a commit that referenced this pull request Oct 31, 2026
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
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 31, 2026
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
@lancewillett

Copy link
Copy Markdown
Member

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