Skip to content

Commit 56e209d

Browse files
committed
Tests: Clean up custom registrations in post and metadata tests.
Unregister fixture post types and taxonomies during teardown in post class, randomable post type, metadata registration, meta revision, and term count transition tests. Developed in: #14987, #14988, #14989, #14990, #14993 Props rejaulalomkhan. See #65893. git-svn-id: https://develop.svn.wordpress.org/trunk@64864 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ac6d406 commit 56e209d

5 files changed

Lines changed: 41 additions & 0 deletions

File tree

‎tests/phpunit/tests/meta/registerMeta.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
2121
}
2222
}
2323

24+
/**
25+
* Tear down after each test.
26+
*/
27+
public function tear_down() {
28+
unregister_post_type( 'test_post_type' );
29+
parent::tear_down();
30+
}
31+
2432
public static function wpTearDownAfterClass() {
2533
wp_delete_post( self::$post_id, true );
2634
wp_delete_term( self::$term_id, 'category' );

‎tests/phpunit/tests/post/getPostClass.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ public function set_up() {
1212
$this->post_id = self::factory()->post->create();
1313
}
1414

15+
/**
16+
* Tear down after each test.
17+
*/
18+
public function tear_down() {
19+
unregister_taxonomy( 'wptests_tax' );
20+
parent::tear_down();
21+
}
22+
1523
public function test_with_tags() {
1624
wp_set_post_terms( $this->post_id, array( 'foo', 'bar' ), 'post_tag' );
1725

‎tests/phpunit/tests/post/metaRevisions.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
* @group meta-revisions
1111
*/
1212
class Tests_Post_MetaRevisions extends WP_UnitTestCase {
13+
/**
14+
* Tear down after each test.
15+
*/
16+
public function tear_down() {
17+
unregister_post_type( 'custom_type' );
18+
parent::tear_down();
19+
}
20+
1321

1422
/**
1523
* Callback function to add the revisioned keys.

‎tests/phpunit/tests/post/randomablePostType.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ protected function get_main_query(): WP_Query {
2626
return $wp_query;
2727
}
2828

29+
/**
30+
* Tear down after each test.
31+
*/
32+
public function tear_down(): void {
33+
unregister_post_type( 'wptests_pt' );
34+
unregister_post_type( 'wptests_noarchive' );
35+
parent::tear_down();
36+
}
37+
2938
/**
3039
* @dataProvider data_built_in_post_types
3140
*

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
5252
wp_set_object_terms( self::$post_id, self::$term_id, self::$taxonomy );
5353
}
5454

55+
/**
56+
* Tear down after each test.
57+
*/
58+
public function tear_down() {
59+
unregister_taxonomy( 'category_with_pending' );
60+
parent::tear_down();
61+
}
62+
5563
/**
5664
* Test that the term count is updated when a post is published.
5765
*

0 commit comments

Comments
 (0)