Skip to content

Tests: Unregister valid_custom_taxonomy in wpSitemapsTaxonomies tests teardown - #15298

Closed
rejaulalomkhan wants to merge 1 commit into
WordPress:trunkfrom
rejaulalomkhan:tests/65893-isolate-sitemaps-valid-custom-taxonomy
Closed

rejaulalomkhan wants to merge 1 commit into
WordPress:trunkfrom
rejaulalomkhan:tests/65893-isolate-sitemaps-valid-custom-taxonomy

Conversation

@rejaulalomkhan

Copy link
Copy Markdown

Description

In Tests_Sitemaps_wpSitemapsTaxonomies (tests/phpunit/tests/sitemaps/wpSitemapsTaxonomies.php), test_sitemap_does_not_404_for_valid_sitemap_subtypes() registers a custom taxonomy (valid_custom_taxonomy) without unregistering it in tear_down().

While other test-specific taxonomies (test_taxonomy, private_taxonomy, non_queryable_tax, public_taxonomy, non_queryable_taxonomy) are accounted for in teardown, valid_custom_taxonomy leaks into global registries, causing potential test pollution for subsequent test classes in the test suite.

This PR adds unregister_taxonomy( 'valid_custom_taxonomy' ) to tear_down() in Tests_Sitemaps_wpSitemapsTaxonomies.

Testing Instructions

  1. Run vendor/bin/phpunit tests/phpunit/tests/sitemaps/wpSitemapsTaxonomies.php -> PASS (10 tests, 26 assertions).
  2. Run vendor/bin/phpunit -c tests/phpunit/multisite.xml tests/phpunit/tests/sitemaps/wpSitemapsTaxonomies.php -> PASS (10 tests, 26 assertions).
  3. Run vendor/bin/phpcs tests/phpunit/tests/sitemaps/wpSitemapsTaxonomies.php -> PASS (0 errors, 0 warnings).

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


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

  • Tool: Antigravity
  • Model: Gemini 3.8 Flash
  • Used for: Identified the missing custom taxonomy unregistration in wpSitemapsTaxonomies.php teardown, updated tear_down(), verified tests locally, and prepared the patch. I reviewed every line, ran the tests listed above, and take responsibility for the change.

@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

There are no active review issues for the taxonomy teardown cleanup intended to improve test isolation.

No open issues 🎉

What changed in this PR

This PR improves test isolation in the sitemap taxonomy tests by cleaning up valid_custom_taxonomy after each test.

Changes:

  • Adds unregister_taxonomy( 'valid_custom_taxonomy' ) to tear_down(), alongside the existing taxonomy cleanup.
File Description
tests/​phpunit/​tests/​sitemaps/​wpSitemapsTaxonomies.php Unregisters the custom taxonomy during teardown to prevent test pollution.

Review effort: Balanced

@lancewillett

Copy link
Copy Markdown
Member

Closing this cleanup-only proposal after tracing the shared Core test lifecycle. The inherited setup resets valid_custom_taxonomy before the next test; these fixtures do not opt out and are not built-in registrations. Class setup runs before that reset, but the inspected existing class fixtures reveal no failing consumer that needs this addition. Benefit unproven; green runs alone demonstrate compatibility, not an isolation fix. We can reconsider a minimal fix if an existing test/order fails without it. Thank you for investigating test isolation.

AI review · gpt-6

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.

3 participants