Skip to content

Tests: Make data providers in canonical.php static - #14792

Draft
shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:tests/65819-static-data-providers-canonical
Draft

shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:tests/65819-static-data-providers-canonical

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

What

Trac ticket: #65819

Makes the data providers in tests/phpunit/tests/canonical.php static.

Why

PHPUnit data providers should be static so they do not depend on test instance state and remain compatible with current PHPUnit usage in Core.

How

  • Convert data_canonical() to public static
  • Convert data_redirect_guess_404_permalink_with_custom_statuses() to public static
  • Convert data_redirect_guess_404_permalink_post_types() to public static
  • Convert data_canonical_attachment_page_redirect_with_option_disabled() to public static

Test-only; no production code changes.

Testing Instructions

  1. npm run test:php -- --filter Tests_Canonical
  2. npm run test:php -- --filter Tests_Canonical -c tests/phpunit/multisite.xml
  3. npm run test:php -- --filter Tests_Canonical --order-by=random
  4. npm run test:php -- --group canonical

Use of AI Tools

  • Cursor

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 changes are limited to instance-independent data providers, with no compatibility conflicts or blocking issues identified.

No open issues 🎉

What changed in this PR

Updates the canonical URL tests to use static PHPUnit data providers, improving compatibility without changing test datasets or production code.

Changes:

  • Adds static to all four specified data provider methods.
  • Preserves existing test behavior; the providers have no instance dependencies.
File Description
tests/​phpunit/​tests/​canonical.php Converts four canonical and redirect data providers to static methods.

Review effort: Balanced

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.

2 participants