Repository navigation
Tests: Remove redundant trailing post type cleanup in Tests_AdminBar - #16267
shail-mehta wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the removal of redundant post type cleanup from the admin bar tests.
No open issues 🎉
What changed in this PR
Simplifies Tests_AdminBar by removing explicit post type cleanup that is handled by the core test framework before each test.
Changes:
- Removes three
unregister_post_type( 'foo-non-public' )calls and adjacent blank lines from archive-link tests. - Leaves post type registration and assertions unchanged.
| File | Description |
|---|---|
tests/phpunit/tests/adminbar.php |
Removes redundant cleanup from three custom post type archive-link tests. |
Review effort: Balanced
|
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:
|
lancewillett
left a comment
There was a problem hiding this comment.
Each archive assertion checks the node already returned by the admin bar. Core removes the ordinary post type before the next test. The archive tests retain their coverage with all three unregister calls removed.
AI review · gpt-6.2-astra
Trac ticket: #66755
What
Removes 3 trailing
unregister_post_type( 'foo-non-public' )calls from the tests inTests_AdminBar(tests/phpunit/tests/adminbar.php):test_admin_bar_has_no_archives_link_for_non_public_cpt()test_admin_bar_has_no_archives_link_for_cpt_without_archive()test_admin_bar_has_no_archives_link_for_cpt_not_shown_in_admin_bar()Why
foo-non-publicis registered inside each test body, not in class-level setup, and is used only intests/phpunit/tests/adminbar.php. So no later class'swpSetUpBeforeClass()depends on it.WP_UnitTestCase_Base::set_up()already resets ordinary post types before every core test viareset_post_types()(tests/phpunit/includes/abstract-testcase.php). So the next test starts withoutfoo-non-publicregistered, and the trailing calls add nothing for later tests.How
Delete the three trailing
unregister_post_type( 'foo-non-public' )calls and the blank line after each.Testing Instructions
Run the class in default and reverse order:
Local results (
npm run test:phpin the Docker environment, PHPUnit 9.6.39, single site):Use of AI Tools