Skip to content

Tests: Unregister custom post type and taxonomy in singleTermTitle tests teardown - #15296

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

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

Conversation

@rejaulalomkhan

Copy link
Copy Markdown

Description

In Tests_General_SingleTermTitle (tests/phpunit/tests/general/singleTermTitle.php), wpSetUpBeforeClass() registers a custom taxonomy (wptests_genre) and set_up() registers both wptests_genre and a custom post type (wptests_book) without unregistering them in wpTearDownAfterClass() or tear_down().

This leaks the custom taxonomy and post type into global registries, causing potential test pollution for subsequent test classes in the test suite.

This PR adds wpTearDownAfterClass() and tear_down() to Tests_General_SingleTermTitle to properly unregister wptests_genre and wptests_book.

Testing Instructions

  1. Run vendor/bin/phpunit tests/phpunit/tests/general/singleTermTitle.php -> PASS (12 tests, 30 assertions).
  2. Run vendor/bin/phpunit -c tests/phpunit/multisite.xml tests/phpunit/tests/general/singleTermTitle.php -> PASS (12 tests, 30 assertions).
  3. Run vendor/bin/phpcs tests/phpunit/tests/general/singleTermTitle.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 and post type unregistration in singleTermTitle.php lifecycle methods, added wpTearDownAfterClass() and 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.

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.

1 participant