Skip to content

Tests: Make data providers in tests/phpunit/tests/rest-api.php public and static - #15299

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

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

Conversation

@rejaulalomkhan

Copy link
Copy Markdown

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

What

Makes the remaining 13 data provider methods in tests/phpunit/tests/rest-api.php public static.

Why

PHPUnit 10+ requires data providers to be public static. These providers only return datasets and do not use $this, so updating their visibility and static modifier brings them into compliance with PHPUnit 10 requirements and aligns with the broader effort on #66211.

How

Update the following data provider methods to public static function:

  • data_jsonp_callback_check()
  • data_rest_parse_date()
  • data_rest_parse_date_force_utc()
  • data_rest_parse_embed_param()
  • data_rest_filter_response_by_context()
  • data_rest_ensure_response_returns_instance_of_wp_rest_response()
  • data_rest_is_object()
  • data_rest_sanitize_object()
  • data_rest_is_array()
  • data_rest_sanitize_array()
  • data_rest_is_integer()
  • data_get_best_type_for_value()
  • data_rest_preload_api_request_embeds_links()

Datasets, test logic, and assertions are unchanged.

Testing Instructions

Run single-site and multisite test suites:

vendor/bin/phpunit --filter Tests_REST_API
vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter Tests_REST_API
vendor/bin/phpcs tests/phpunit/tests/rest-api.php

All 449 tests (962 assertions) pass on both suites with zero PHPCS errors.

Use of AI Tools

AI assistance: Yes
Tool: Antigravity
Model: Gemini 3.8 Flash
Used for: Static data provider conversion, local verification via PHPUnit/PHPCS, and PR description generation.

… and static

Makes remaining data providers in `tests/phpunit/tests/rest-api.php` `public static` in preparation for PHPUnit 10:
- `data_jsonp_callback_check`
- `data_rest_parse_date`
- `data_rest_parse_date_force_utc`
- `data_rest_parse_embed_param`
- `data_rest_filter_response_by_context`
- `data_rest_ensure_response_returns_instance_of_wp_rest_response`
- `data_rest_is_object`
- `data_rest_sanitize_object`
- `data_rest_is_array`
- `data_rest_sanitize_array`
- `data_rest_is_integer`
- `data_get_best_type_for_value`
- `data_rest_preload_api_request_embeds_links`

See #66211.
@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

The PHPUnit 10+ data-provider compatibility update has no active review issues.

No open issues 🎉

What changed in this PR

Updates the remaining 13 data providers in the REST API test class to meet PHPUnit 10+ requirements, supporting the broader test compatibility work in Trac #66211.

Changes:

  • Adds static to 13 existing public data provider methods.
  • Leaves datasets, test logic, and assertions unchanged.
File Description
tests/​phpunit/​tests/​rest-api.php Converts the remaining 13 data providers to public static.

Review effort: Balanced

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

LGTM!

@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 13 providers are independent of instance state; their datasets and assertions are unchanged. PHPCS and randomized local single-site and multisite runs passed: 263 tests, 402 assertions in each mode.

AI review · gpt-6

wporg-sync pushed a commit that referenced this pull request Oct 31, 2026
Declare the remaining 13 data providers in `tests/phpunit/tests/rest-api.php` as `public static` for PHPUnit compatibility. Preserve existing datasets and assertions.

Developed in: #15299

Props rejaulalomkhan, huzaifaalmesbah.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@65127 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 31, 2026
Declare the remaining 13 data providers in `tests/phpunit/tests/rest-api.php` as `public static` for PHPUnit compatibility. Preserve existing datasets and assertions.

Developed in: WordPress/wordpress-develop#15299

Props rejaulalomkhan, huzaifaalmesbah.
See #66211.

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


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