Skip to content

Tests: Unregister custom taxonomies and post type in term tests teardown - #15089

Open
rejaulalomkhan wants to merge 1 commit into
WordPress:trunkfrom
rejaulalomkhan:tests/65893-isolate-tests-term
Open

rejaulalomkhan wants to merge 1 commit into
WordPress:trunkfrom
rejaulalomkhan:tests/65893-isolate-tests-term

Conversation

@rejaulalomkhan

Copy link
Copy Markdown

Description

In Tests_Term (tests/phpunit/tests/term.php), multiple test methods register custom taxonomies ('wptests_tax', 'wptests_tax_hierarchical') and a custom post type ('cpt'). Without a tear_down() implementation, these taxonomies and post type remain in global state after the tests execute.

This PR adds a tear_down() method to Tests_Term to cleanly unregister 'wptests_tax', 'wptests_tax_hierarchical', and 'cpt' after each test.

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 2.5 Pro
  • Use: Identification of global state test isolation leaks and drafting the unregister calls in teardown.

@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 remain for the test-isolation cleanup.

No open issues 🎉

What changed in this PR

This PR improves test isolation in Tests_Term by cleaning up custom registrations after each test, preventing them from leaking into subsequent tests.

Changes:

  • Adds tear_down() to unregister the wptests_tax and wptests_tax_hierarchical taxonomies and the cpt post type.
  • Calls parent::tear_down() after the custom cleanup.
File Description
tests/​phpunit/​tests/​term.php Adds per-test cleanup for custom taxonomies and the custom post type.

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 fixture ownership and teardown order, including shared term fixtures and administrator capabilities. The combined affected suites passed three randomized seeds in single-site (921 tests, 3440 assertions) and multisite (931 tests, 3674 assertions), with no warnings or skips. Baseline passed with matching counts. PHPCS, CI, and current-head Copilot reviews are clear.

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.

4 participants