diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index 21b9977a85366..e81f38f53dbcc 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -16,6 +16,30 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) ); } + /** + * Tear down after each test. + */ + public function tear_down() { + unregister_taxonomy( 'wptests_tax' ); + unregister_taxonomy( 'wptests_tax_1' ); + unregister_taxonomy( 'wptests_tax_2' ); + unregister_taxonomy( 'wptests_conflict' ); + unregister_taxonomy( 'taxonomy53212' ); + unregister_taxonomy( 'random' ); + unregister_taxonomy( 'foo' ); + unregister_taxonomy( 'tax_new' ); + unregister_taxonomy( 'test_tax' ); + unregister_taxonomy( 'custom-tax' ); + unregister_taxonomy( 'test_tax1' ); + unregister_taxonomy( 'test_tax2' ); + unregister_post_type( 'test_cpt' ); + unregister_post_type( 'wptests_pt' ); + unregister_post_type( 'wptests_conflict' ); + unregister_post_type( 'post-custom-tax' ); + unregister_post_type( 'test_post_type' ); + parent::tear_down(); + } + public function test_get_post_taxonomies() { $this->assertSame( array( 'category', 'post_tag', 'post_format' ), get_object_taxonomies( 'post' ) ); } @@ -212,7 +236,7 @@ public function test_register_taxonomy() { $this->assertFalse( is_taxonomy_hierarchical( $tax ) ); // Clean up. - unset( $GLOBALS['wp_taxonomies'][ $tax ] ); + unregister_taxonomy( $tax ); } public function test_register_hierarchical_taxonomy() { @@ -226,7 +250,7 @@ public function test_register_hierarchical_taxonomy() { $this->assertTrue( is_taxonomy_hierarchical( $tax ) ); // Clean up. - unset( $GLOBALS['wp_taxonomies'][ $tax ] ); + unregister_taxonomy( $tax ); } /** @@ -341,7 +365,7 @@ public function test_registering_taxonomies_to_object_types() { $this->assertFalse( register_taxonomy_for_object_type( $tax, 'user' ) ); $this->assertFalse( unregister_taxonomy_for_object_type( $tax, 'user' ) ); - unset( $GLOBALS['wp_taxonomies'][ $tax ] ); + unregister_taxonomy( $tax ); _unregister_post_type( $post_type ); } @@ -646,7 +670,6 @@ public function test_get_ancestors_taxonomy_post_type_conflict_resource_type_tax $this->assertSameSets( array( $p1 ), get_ancestors( $p2, 'wptests_conflict', 'post_type' ) ); $this->assertSameSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict', 'taxonomy' ) ); $this->assertSameSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict' ) ); - _unregister_post_type( 'wptests_pt' ); } /**