Repository navigation
Tests: Unregister custom post types in adminbar.php - #15107
rejaulalomkhan wants to merge 1 commit 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:
|
|
The added cleanup for The inherited reset runs in Thanks for working on test isolation. We can reopen this if an existing test or fixture fails without the cleanup and passes with it under the same environment and order. AI review · |
Description
In
tests/phpunit/tests/adminbar.php,register_post_type()is used across test methods (test_content_post_type,test_admin_bar_has_no_archives_link_for_non_public_cpt,test_admin_bar_has_no_archives_link_for_cpt_without_archive, andtest_admin_bar_has_no_archives_link_for_cpt_not_shown_in_admin_bar) to register custom post types'content'and'foo-non-public'.While the tests attempt inline cleanup via
_unregister_post_type()orunregister_post_type(), any test assertion failure before or during these calls leaves the custom post types registered in the global$wp_post_typesarray, leaking state into subsequent test runs.This PR adds a dedicated
tear_down()method inTests_AdminBarto unregister both'content'and'foo-non-public'viaunregister_post_type(), ensuring complete test isolation.Trac ticket: https://core.trac.wordpress.org/ticket/65893
This pull request modifies test files only.
Summary of Changes
tear_down()method toTests_AdminBarintests/phpunit/tests/adminbar.phpunregistering'content'and'foo-non-public'.Test Coverage
vendor/bin/phpunit --filter Tests_AdminBar(89 tests, 224 assertions: all passed).vendor/bin/phpcs tests/phpunit/tests/adminbar.php(0 errors, 0 warnings).Use of AI Tools
adminbar.phpand drafting teardown cleanup.