Repository navigation
Tests: Remove redundant registration cleanup from post and query tests - #15189
lancewillett wants to merge 3 commits into
Conversation
|
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: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the removal of redundant test-registration cleanup.
No open issues 🎉
What changed in this PR
This PR simplifies WordPress Core tests by removing registration cleanup that duplicates the base test setup’s resets, following the additions in #65893. Production code and the base test lifecycle remain unchanged.
Changes:
- Remove cleanup-only teardown overrides for post types, taxonomies, and custom post statuses.
- Remove class-level post-type cleanup in two query test classes.
- Preserve assertions, scenario-specific unregister calls, unrelated fixture cleanup, and deliberate built-in post-type cleanup.
| File | Description |
|---|---|
tests/phpunit/tests/user/theAuthorPosts.php |
Remove post-type cleanup; retain global cleanup. |
tests/phpunit/tests/user/queryCache.php |
Remove post-type teardown override. |
tests/phpunit/tests/user/query.php |
Remove public/private post-type teardown. |
tests/phpunit/tests/user/countUserPosts.php |
Remove post-type teardown override. |
tests/phpunit/tests/query/taxQuery.php |
Remove taxonomy and post-type teardown. |
tests/phpunit/tests/query/search.php |
Remove post-type cleanup; retain query cleanup. |
tests/phpunit/tests/query/results.php |
Remove handbook post-type teardown. |
tests/phpunit/tests/query/randomContentRedirect.php |
Remove post-type and taxonomy teardown. |
tests/phpunit/tests/query/postStatus.php |
Remove class-level and per-test registration cleanup. |
tests/phpunit/tests/query/lazyLoadTermMeta.php |
Remove taxonomy teardown override. |
tests/phpunit/tests/query/isTerm.php |
Remove test-taxonomy teardown. |
tests/phpunit/tests/query/fieldsClause.php |
Remove class-level and per-test post-type cleanup. |
tests/phpunit/tests/query/conditionals.php |
Remove post-type teardown override. |
tests/phpunit/tests/query/cacheResults.php |
Remove taxonomy teardown override. |
tests/phpunit/tests/post/wpPublishPost.php |
Remove taxonomy teardown override. |
tests/phpunit/tests/post/updateTermCountOnTransitionPostStatus.php |
Remove taxonomy and custom-status teardown. |
tests/phpunit/tests/post/types.php |
Remove registration cleanup override. |
tests/phpunit/tests/post/randomablePostType.php |
Remove custom post-type teardown. |
tests/phpunit/tests/post/nav-menu.php |
Remove post-type and taxonomy teardown. |
tests/phpunit/tests/post/metaRevisions.php |
Remove custom post-type teardown. |
tests/phpunit/tests/post/getPostClass.php |
Remove taxonomy teardown override. |
tests/phpunit/tests/post/getPages.php |
Remove custom-status and post-type teardown. |
tests/phpunit/tests/post/getPageByPath.php |
Remove post-type teardown override. |
tests/phpunit/tests/post/getLastPostModified.php |
Remove book post-type teardown. |
tests/phpunit/tests/post/getLastPostDate.php |
Remove book post-type teardown. |
tests/phpunit/tests/post/getBodyClass.php |
Remove taxonomy cleanup; retain theme restoration. |
tests/phpunit/tests/post.php |
Remove registration teardown; retain role cleanup. |
tests/phpunit/tests/comment/query.php |
Remove post-type cleanup; retain fixture cleanup. |
Review effort: Balanced
|
Narrowed in 7c3292d and 0ea4331: retain the query classes’ existing class callbacks and exclude Randomized baseline/patched comparisons passed with identical counts: 1,220 tests single-site and 1,238 multisite, with four unchanged expectation-deprecation warnings and one skip. Peter’s independent review remains pending. AI review · |
|
Follow-up on the class-boundary concern: I ran the existing This is bounded evidence only. The next class fixture can still see a registration before the per-test reset, and the restored class callbacks cover only their named registrations. This comparison did not demonstrate a failing consumer or establish whole-suite class-boundary equivalence. Keeping the independent review hold; no extra cleanup or synthetic tests added. AI review · |
Core's inherited test setup resets ordinary post types, taxonomies, and non-built-in statuses before each test. Remove duplicate per-test cleanup while retaining scenario-specific unregister calls and unrelated fixture cleanup.
Keep the existing class callbacks in
query/fieldsClause.phpandquery/postStatus.php. Class setup precedes per-test reset, so the per-test reset alone does not justify deleting those callbacks. Leavequery/randomContentRedirect.phpout of this PR; its cleanup is unchanged.The deliberate built-in post-type cleanup in
post/isPostTypeViewable.phpremains untouched. No new tests or assertions.See https://core.trac.wordpress.org/ticket/65893.
Validation on current trunk with this patch applied independently: PHP syntax and PHPCS passed. Randomized seed
15189produced identical baseline/patched results: single-site 1,220 tests / 4,085 assertions; multisite 1,238 tests / 4,160 assertions. Four existing PHPUnit expectation-deprecation warnings and one skip remain in both variants. These runs bound compatibility; independent review of class-boundary behavior remains pending.Prepared with AI assistance (gpt-6).