Skip to content

Tests: Make data providers in functions, media, meta, and vars tests public static - #15310

Closed
devmuhib009 wants to merge 1 commit into
WordPress:trunkfrom
devmuhib009:tests/66211-functions-media-meta-vars-static-providers
Closed

devmuhib009 wants to merge 1 commit into
WordPress:trunkfrom
devmuhib009:tests/66211-functions-media-meta-vars-static-providers

Conversation

@devmuhib009

Copy link
Copy Markdown
Member

Under Trac ticket #66211 and following committer guidance (Trac #66211 comment 109), this PR updates data provider methods across single-test files in functions, media, meta, and vars to be public static.

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

What

Declare data provider methods as public static:

  • Tests_Functions__WpCheckExistingFileNames::data_wp_check_existing_file_names() in tests/phpunit/tests/functions/_wpCheckExistingFileNames.php
  • Tests_Media_GetMediaEmbeddedInContent::data_content() in tests/phpunit/tests/media/getMediaEmbeddedInContent.php
  • Tests_Meta::data_get_metadata_with_non_existent_object_id() in tests/phpunit/tests/meta.php
  • Tests_Vars::get_data_to_test_wp_is_mobile() in tests/phpunit/tests/vars.php

Why

PHPUnit 10+ requires data providers to be public static. These methods do not use $this and return static datasets, so declaring them public static prepares the test suite for modern PHPUnit versions without changing test behavior.

Testing Instructions

Run the test suite and coding standards check:

vendor/bin/phpunit --filter "Tests_Functions__WpCheckExistingFileNames|Tests_Media_GetMediaEmbeddedInContent|Tests_Meta|Tests_Vars"
vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter "Tests_Functions__WpCheckExistingFileNames|Tests_Media_GetMediaEmbeddedInContent|Tests_Meta|Tests_Vars"
vendor/bin/phpcs tests/phpunit/tests/functions/_wpCheckExistingFileNames.php tests/phpunit/tests/media/getMediaEmbeddedInContent.php tests/phpunit/tests/meta.php tests/phpunit/tests/vars.php

All tests pass cleanly.

…public static. See #66211. Props devmuhib009.
@github-actions

github-actions Bot commented Nov 1, 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 devmuhib.

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.

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

Thanks! All four providers are static and nothing else changes. LGTM.

AI Review: Opus 5.5

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 block the PHPUnit 10+ data-provider compatibility change.

No open issues 🎉

What changed in this PR

This PR prepares four WordPress test data providers for PHPUnit 10+ by declaring them public static, supporting the compatibility work tracked in Trac #66211.

Changes:

  • Updates provider declarations in the functions, media, meta, and vars tests.
  • Leaves datasets and test assertions unchanged.
File Description
tests/​phpunit/​tests/​vars.php Makes the mobile-detection data provider static.
tests/​phpunit/​tests/​meta.php Makes the nonexistent-object metadata provider static.
tests/​phpunit/​tests/​media/​getMediaEmbeddedInContent.php Makes the embedded-media content provider static.
tests/​phpunit/​tests/​functions/​_wpCheckExistingFileNames.php Makes the existing-filename check provider static.

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.

Reviewed the changed code against the implementation and existing coverage; no blocking issue found.

Validated with the related provider/factory patches on current trunk: 1,108 tests and 2,503 assertions in each of single-site and multisite, randomized seed 1101. The same two environment-dependent skips occurred before and after; no failures or errors.

Current-head CI and Copilot review checked.

AI review · gpt-6

wporg-sync pushed a commit that referenced this pull request Nov 1, 2026
Update post, database, view configuration, bookmark, admin, media, metadata, and variable test providers for newer PHPUnit versions. Use static calls for the media dimension helpers without changing datasets or assertions.

Developed in: #15270, #15308, #15309, #15310, #15311

Props shailu25, rejaulalomkhan, devmuhib, huzaifaalmesbah.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@65162 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 1, 2026
Update post, database, view configuration, bookmark, admin, media, metadata, and variable test providers for newer PHPUnit versions. Use static calls for the media dimension helpers without changing datasets or assertions.

Developed in: WordPress/wordpress-develop#15270, WordPress/wordpress-develop#15308, WordPress/wordpress-develop#15309, WordPress/wordpress-develop#15310, WordPress/wordpress-develop#15311

Props shailu25, rejaulalomkhan, devmuhib, huzaifaalmesbah.
See #66211.

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


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