Skip to content

Tests: Make data providers in tests/phpunit/tests/script-modules/ public and static - #15102

Closed
rejaulalomkhan wants to merge 1 commit into
WordPress:trunkfrom
rejaulalomkhan:tests/66211-static-dp-script-modules
Closed

rejaulalomkhan wants to merge 1 commit into
WordPress:trunkfrom
rejaulalomkhan:tests/66211-static-dp-script-modules

Conversation

@rejaulalomkhan

@rejaulalomkhan rejaulalomkhan commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Description

PHPUnit data providers that do not rely on test state or $this should be declared as public static to optimize test execution performance and comply with modern PHPUnit standards.

Data providers updated in tests/phpunit/tests/script-modules/wpScriptModules.php:

  • data_test_register_and_enqueue_script_module() -> public static function
  • data_provider_fetchpriority_values() -> public static function
  • data_provider_to_test_fetchpriority_bumping() -> public static function

Testing Instructions

  1. Run vendor/bin/phpunit --filter test_comprehensive_methods tests/phpunit/tests/script-modules/wpScriptModules.php -> PASS (4 tests, 300 assertions).
  2. Run vendor/bin/phpunit --filter fetchpriority tests/phpunit/tests/script-modules/wpScriptModules.php -> PASS (12 tests, 79 assertions).
  3. Run vendor/bin/phpcs tests/phpunit/tests/script-modules/ -> PASS (0 errors, 0 warnings).

Trac ticket: https://core.trac.wordpress.org/ticket/66211


This Pull Request is for code review only. Please keep all other discussion to 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

  • Tool: Google Antigravity / Gemini 3.8 Flash
  • Purpose: Audited tests/phpunit/tests/script-modules/ directory, converted data providers to public static, and verified via PHPUnit/PHPCS. All changes inspected and verified locally before submission.

@github-actions

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.

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.

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 identified for the change making three PHPUnit data providers public static.

No open issues 🎉

What changed in this PR

This PR updates three data providers in the script-module PHPUnit tests to use public static declarations, aligning them with modern PHPUnit requirements without changing test data or assertions.

Changes:

  • Makes the registration/enqueue provider and two fetch-priority providers static.
File Description
tests/​phpunit/​tests/​script-modules/​wpScriptModules.php Adds static to three public data-provider methods.

Review effort: Balanced

@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 providers do not rely on test-instance state, and the datasets and assertions are unchanged. PHPCS passed on all changed files. The combined three-PR batch passed randomized single-site and multisite runs: 219 tests and 1,311 assertions per mode, seed 66211.

AI review · gpt-6

wporg-sync pushed a commit that referenced this pull request Oct 29, 2026
Declare ten data providers in the style-engine, script-module, and load tests as `public static` for compatibility with newer PHPUnit versions. Add explicit `array` return types to the five load providers. Preserve all datasets and assertions.

Developed in: #15098, #15102, #15153

Props rejaulalomkhan, therssoftware, mukesh27.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@65027 602fd350-edb4-49c9-b593-d223f7449a82
@lancewillett

Copy link
Copy Markdown
Member

wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 29, 2026
Declare ten data providers in the style-engine, script-module, and load tests as `public static` for compatibility with newer PHPUnit versions. Add explicit `array` return types to the five load providers. Preserve all datasets and assertions.

Developed in: WordPress/wordpress-develop#15098, WordPress/wordpress-develop#15102, WordPress/wordpress-develop#15153

Props rejaulalomkhan, therssoftware, mukesh27.
See #66211.

Built from https://develop.svn.wordpress.org/trunk@65027


git-svn-id: http://core.svn.wordpress.org/trunk@64177 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