Skip to content

Tests: Remove redundant taxonomy cleanup in Tests_Query_DateQuery::test_date_query_with_taxonomy_join() - #16268

Open
shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:tests/66755-remove-redundant-taxonomy-cleanup-date-query
Open

shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:tests/66755-remove-redundant-taxonomy-cleanup-date-query

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

Trac ticket: #66755

What

Removes the _unregister_taxonomy( 'foo' ) call from Tests_Query_DateQuery::test_date_query_with_taxonomy_join() (tests/phpunit/tests/query/dateQuery.php). The assertion and the rest of the test are unchanged.

Why

The foo taxonomy is registered inside the test body, not in class-level setup. The assertion checks the query result, which is computed before the unregister call, so nothing after the call depends on foo being unregistered.

WP_UnitTestCase_Base::set_up() already resets ordinary taxonomies before every core test via reset_taxonomies(). So the next test starts without foo registered, and the unregister adds nothing for later tests.

No class-level setup in the test suite registers the foo taxonomy. Its registrations are all inside test bodies, so a registration left behind by the last test cannot affect a later class's wpSetUpBeforeClass().

How

Delete the _unregister_taxonomy( 'foo' ); line after the query and before the assertion.

Testing Instructions

Run the class in default and reverse order, and the query group:

npm run test:php -- --filter Tests_Query_DateQuery
npm run test:php -- --order-by=reverse --filter Tests_Query_DateQuery
npm run test:php -- --group query

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 review identifies no active issues with removing the date-query test’s explicit taxonomy cleanup.

No open issues 🎉

What changed in this PR

This PR simplifies taxonomy cleanup in the date-query test, relying on the core test framework’s existing per-test taxonomy reset.

Changes:

  • Removes _unregister_taxonomy( 'foo' ) from test_date_query_with_taxonomy_join().
  • Leaves the query and result assertion unchanged.
File Description
tests/​phpunit/​tests/​query/​dateQuery.php Removes the explicit taxonomy cleanup call from the taxonomy-join test.

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review November 26, 2026 16:31
@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 shailu25.

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 or WordPress.org 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.

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

The posts have already been fetched when the cleanup runs. The next test gets a fresh taxonomy registry, and the class fixture that enumerates post taxonomies filters out this non-built-in taxonomy.

AI review · gpt-6.2-astra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants