Skip to content

Commit 7d17326

Browse files
committed
Tests: Clean up registrations in post, term, and user tests.
Unregister custom post types, taxonomies, and post statuses during teardown in the post-status transition, navigation menu, post, term metadata, and user query tests. Prevent these registrations from leaking into subsequent tests. Developed in: #15074, #15075, #15076, #15077, #15078 Props rejaulalomkhan, mukesh27. See #65893. git-svn-id: https://develop.svn.wordpress.org/trunk@65025 602fd350-edb4-49c9-b593-d223f7449a82
1 parent a030e8c commit 7d17326

5 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎tests/phpunit/tests/post.php‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ public static function wpTearDownAfterClass() {
6060
remove_role( 'grammarian' );
6161
}
6262

63+
/**
64+
* Tear down after each test.
65+
*/
66+
public function tear_down() {
67+
unregister_post_type( 'restless' );
68+
unregister_post_type( 'new_post_type' );
69+
unregister_taxonomy( 'new_tag' );
70+
_unregister_post_status( 'test' );
71+
72+
parent::tear_down();
73+
}
74+
6375
public function test_parse_post_content_single_page() {
6476
global $multipage, $pages, $numpages;
6577

‎tests/phpunit/tests/post/nav-menu.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function set_up() {
1818
public function tear_down() {
1919
unregister_post_type( 'fooo-bar-baz' );
2020
unregister_post_type( 'books' );
21+
unregister_taxonomy( 'wptests_tax' );
2122

2223
parent::tear_down();
2324
}

‎tests/phpunit/tests/post/updateTermCountOnTransitionPostStatus.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
5757
*/
5858
public function tear_down() {
5959
unregister_taxonomy( 'category_with_pending' );
60+
_unregister_post_status( 'counted' );
6061
parent::tear_down();
6162
}
6263

‎tests/phpunit/tests/term/meta.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ public function set_up() {
1818
register_taxonomy( 'wptests_tax', 'post' );
1919
}
2020

21+
public function tear_down() {
22+
unregister_taxonomy( 'wptests_tax' );
23+
unregister_taxonomy( 'wptests_tax_2' );
24+
unregister_taxonomy( 'wptests_tax_3' );
25+
26+
parent::tear_down();
27+
}
28+
2129
public function test_add() {
2230
$t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
2331

‎tests/phpunit/tests/user/query.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
4949
);
5050
}
5151

52+
/**
53+
* Tear down after each test.
54+
*/
55+
public function tear_down() {
56+
unregister_post_type( 'wptests_pt_public' );
57+
unregister_post_type( 'wptests_pt_private' );
58+
59+
parent::tear_down();
60+
}
61+
5262
public function test_get_and_set() {
5363
$users = new WP_User_Query();
5464

0 commit comments

Comments
 (0)