Ticket #35227: 35227.diff
| File 35227.diff, 39.5 KB (added by , 10 years ago) |
|---|
-
src/wp-includes/class-wp-rewrite.php
diff --git src/wp-includes/class-wp-rewrite.php src/wp-includes/class-wp-rewrite.php index 035bbc3..467f823 100644
class WP_Rewrite { 842 842 } 843 843 844 844 /** 845 * Adds or updates existing rewrite tags (e.g. %postname%). 846 * 847 * If the tag already exists, replace the existing pattern and query for 848 * that tag, otherwise add the new tag. 849 * 850 * @since 4.5.0 851 * @access public 852 * 853 * @see WP_Rewrite::$rewritecode 854 * @see WP_Rewrite::$rewritereplace 855 * @see WP_Rewrite::$queryreplace 856 * 857 * @param string $tag Name of the rewrite tag. 858 */ 859 public function remove_rewrite_tag( $tag ) { 860 $position = array_search( $tag, $this->rewritecode ); 861 if ( false !== $position && null !== $position ) { 862 unset( $this->rewritecode[ $position ] ); 863 unset( $this->rewritereplace[ $position ] ); 864 unset( $this->queryreplace[ $position ] ); 865 } 866 } 867 868 /** 845 869 * Generates rewrite rules from a permalink structure. 846 870 * 847 871 * The main WP_Rewrite function for building the rewrite rule list. The -
src/wp-includes/rewrite.php
diff --git src/wp-includes/rewrite.php src/wp-includes/rewrite.php index 7f3b2ed..826ced2 100644
function add_rewrite_tag( $tag, $regex, $query = '' ) { 173 173 } 174 174 175 175 /** 176 * Removes an existing rewrite tag (like %postname%). 177 * 178 * @since 4.5.0 179 * 180 * @global WP_Rewrite $wp_rewrite WordPress rewrite component. 181 * @global WP $wp Current WordPress environment instance. 182 * 183 * @param string $tag Name of the rewrite tag. 184 */ 185 function remove_rewrite_tag( $tag ) { 186 global $wp_rewrite; 187 $wp_rewrite->remove_rewrite_tag( $tag ); 188 } 189 190 /** 176 191 * Add permalink structure. 177 192 * 178 193 * @since 3.0.0 -
src/wp-includes/taxonomy.php
diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php index 8cbef3c..02ac213 100644
function register_taxonomy( $taxonomy, $object_type, $args = array() ) { 473 473 } 474 474 475 475 /** 476 * Unregister a taxonomy. 477 * 478 * @since 4.5.0 479 * 480 * @global WP_Rewrite $wp_rewrite WordPress rewrite component. 481 * @global WP $wp Current WordPress environment instance. 482 * @global array $wp_taxonomies List of taxonomies. 483 * 484 * @param string $taxonomy Taxonomy name. 485 * @return bool True on success, false on failure. 486 */ 487 function unregister_taxonomy( $taxonomy ) { 488 if ( ! taxonomy_exists( $taxonomy ) ) { 489 return false; 490 } 491 492 $taxonomy_args = get_taxonomy( $taxonomy ); 493 494 // Do not allow unregistering internal taxonomies. 495 if ( $taxonomy_args->_builtin ) { 496 return false; 497 } 498 499 global $wp_taxonomies, $wp_rewrite, $wp; 500 501 // Remove query vars. 502 if ( false !== $taxonomy_args->query_var ) { 503 $wp->public_query_vars = array_diff( $wp->public_query_vars, array( $taxonomy_args->query_var ) ); 504 } 505 506 // Remove any rewrite rules, permastructs, and rules. 507 if ( false !== $taxonomy_args->rewrite ) { 508 remove_rewrite_tag( "%$taxonomy%" ); 509 unset( $wp_rewrite->extra_permastructs[ $taxonomy ] ); 510 } 511 512 // Unregister callback handling for metabox. 513 remove_all_actions( 'wp_ajax_add-' . $taxonomy ); 514 515 // Remove the taxonomy. 516 unset( $wp_taxonomies[ $taxonomy ] ); 517 518 /** 519 * Fires after a taxonomy is unregistered. 520 * 521 * @since 4.5.0 522 * 523 * @param string $taxonomy Taxonomy name. 524 */ 525 do_action( 'unregistered_taxonomy', $taxonomy ); 526 527 return true; 528 } 529 530 /** 476 531 * Builds an object with all taxonomy labels out of a taxonomy object 477 532 * 478 533 * Accepted keys of the label array in the taxonomy object: -
tests/phpunit/includes/testcase.php
diff --git tests/phpunit/includes/testcase.php tests/phpunit/includes/testcase.php index a468deb..f9a98da 100644
class WP_UnitTestCase extends PHPUnit_Framework_TestCase { 171 171 */ 172 172 protected function reset_taxonomies() { 173 173 foreach ( get_taxonomies() as $tax ) { 174 _unregister_taxonomy( $tax );174 unregister_taxonomy( $tax ); 175 175 } 176 176 create_initial_taxonomies(); 177 177 } -
tests/phpunit/includes/utils.php
diff --git tests/phpunit/includes/utils.php tests/phpunit/includes/utils.php index 0a6dfc1..47b6885 100644
function _unregister_post_type( $cpt_name ) { 333 333 } 334 334 } 335 335 336 function _unregister_taxonomy( $taxonomy_name ) {337 unset( $GLOBALS['wp_taxonomies'][$taxonomy_name] );338 }339 340 336 /** 341 337 * Unregister a post status. 342 338 * … … class wpdb_exposed_methods_for_testing extends wpdb { 398 394 */ 399 395 function benchmark_pcre_backtracking( $pattern, $subject, $strategy ) { 400 396 $saved_config = ini_get( 'pcre.backtrack_limit' ); 401 397 402 398 // Attempt to prevent PHP crashes. Adjust these lower when needed. 403 399 if ( version_compare( phpversion(), '5.4.8', '>' ) ) { 404 400 $limit = 1000000; … … function benchmark_pcre_backtracking( $pattern, $subject, $strategy ) { 410 406 for( $i = 4; $i <= $limit; $i *= 2 ) { 411 407 412 408 ini_set( 'pcre.backtrack_limit', $i ); 413 409 414 410 switch( $strategy ) { 415 411 case 'split': 416 412 preg_split( $pattern, $subject ); -
tests/phpunit/tests/category.php
diff --git tests/phpunit/tests/category.php tests/phpunit/tests/category.php index 913f4dc..730f5d5 100644
10 10 class Tests_Category extends WP_UnitTestCase { 11 11 12 12 function tearDown() { 13 _unregister_taxonomy( 'test_tax_cat' );13 unregister_taxonomy( 'test_tax_cat' ); 14 14 parent::tearDown(); 15 15 } 16 16 -
tests/phpunit/tests/query/dateQuery.php
diff --git tests/phpunit/tests/query/dateQuery.php tests/phpunit/tests/query/dateQuery.php index f40302d..7aadc8d 100644
class Tests_Query_DateQuery extends WP_UnitTestCase { 848 848 ), 849 849 ) ); 850 850 851 _unregister_taxonomy( 'foo' );851 unregister_taxonomy( 'foo' ); 852 852 853 853 $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); 854 854 } -
tests/phpunit/tests/query/isTerm.php
diff --git tests/phpunit/tests/query/isTerm.php tests/phpunit/tests/query/isTerm.php index c9a4160..294b33d 100644
class Tests_Query_IsTerm extends WP_UnitTestCase { 58 58 function tearDown() { 59 59 global $wp_rewrite; 60 60 61 _unregister_taxonomy( 'testtax' );61 unregister_taxonomy( 'testtax' ); 62 62 63 63 $wp_rewrite->init(); 64 64 -
tests/phpunit/tests/query/taxQuery.php
diff --git tests/phpunit/tests/query/taxQuery.php tests/phpunit/tests/query/taxQuery.php index 8248b19..6265afa 100644
class Tests_Query_TaxQuery extends WP_UnitTestCase { 691 691 ), 692 692 ) ); 693 693 694 _unregister_taxonomy( 'foo' );695 _unregister_taxonomy( 'bar' );694 unregister_taxonomy( 'foo' ); 695 unregister_taxonomy( 'bar' ); 696 696 697 697 $this->assertEqualSets( array( $p1, $p2 ), $q->posts ); 698 698 } … … class Tests_Query_TaxQuery extends WP_UnitTestCase { 755 755 ), 756 756 ) ); 757 757 758 _unregister_taxonomy( 'foo' );759 _unregister_taxonomy( 'bar' );758 unregister_taxonomy( 'foo' ); 759 unregister_taxonomy( 'bar' ); 760 760 761 761 $this->assertEqualSets( array( $p1, $p2 ), $q->posts ); 762 762 } … … class Tests_Query_TaxQuery extends WP_UnitTestCase { 828 828 ), 829 829 ) ); 830 830 831 _unregister_taxonomy( 'foo' );832 _unregister_taxonomy( 'bar' );831 unregister_taxonomy( 'foo' ); 832 unregister_taxonomy( 'bar' ); 833 833 834 834 $this->assertEqualSets( array( $p1, $p2, $p3 ), $q->posts ); 835 835 } … … class Tests_Query_TaxQuery extends WP_UnitTestCase { 1185 1185 1186 1186 $this->assertSame( 'foo', $q->get( 'taxonomy' ) ); 1187 1187 1188 _unregister_taxonomy( 'foo' );1188 unregister_taxonomy( 'foo' ); 1189 1189 } 1190 1190 1191 1191 public function test_populate_taxonomy_query_var_from_tax_query_taxonomy_already_set() { … … class Tests_Query_TaxQuery extends WP_UnitTestCase { 1207 1207 1208 1208 $this->assertSame( 'bar', $q->get( 'taxonomy' ) ); 1209 1209 1210 _unregister_taxonomy( 'foo' );1211 _unregister_taxonomy( 'foo1' );1210 unregister_taxonomy( 'foo' ); 1211 unregister_taxonomy( 'foo1' ); 1212 1212 } 1213 1213 1214 1214 public function test_populate_term_query_var_from_tax_query() { … … class Tests_Query_TaxQuery extends WP_UnitTestCase { 1230 1230 1231 1231 $this->assertSame( 'bar', $q->get( 'term' ) ); 1232 1232 1233 _unregister_taxonomy( 'foo' );1233 unregister_taxonomy( 'foo' ); 1234 1234 } 1235 1235 1236 1236 public function test_populate_term_id_query_var_from_tax_query() { … … class Tests_Query_TaxQuery extends WP_UnitTestCase { 1252 1252 1253 1253 $this->assertEquals( $t, $q->get( 'term_id' ) ); 1254 1254 1255 _unregister_taxonomy( 'foo' );1255 unregister_taxonomy( 'foo' ); 1256 1256 } 1257 1257 1258 1258 /** … … class Tests_Query_TaxQuery extends WP_UnitTestCase { 1293 1293 $this->assertEquals( $c, $q->get( 'cat' ) ); 1294 1294 $this->assertEquals( 'bar', $q->get( 'category_name' ) ); 1295 1295 1296 _unregister_taxonomy( 'foo' );1296 unregister_taxonomy( 'foo' ); 1297 1297 } 1298 1298 1299 1299 /** … … class Tests_Query_TaxQuery extends WP_UnitTestCase { 1333 1333 1334 1334 $this->assertEquals( $tag, $q->get( 'tag_id' ) ); 1335 1335 1336 _unregister_taxonomy( 'foo' );1336 unregister_taxonomy( 'foo' ); 1337 1337 } 1338 1338 } -
tests/phpunit/tests/taxonomy.php
diff --git tests/phpunit/tests/taxonomy.php tests/phpunit/tests/taxonomy.php index 2063bbe..f4b68bc 100644
class Tests_Taxonomy extends WP_UnitTestCase { 235 235 $this->assertFalse( unregister_taxonomy_for_object_type( $tax, 'user' ) ); 236 236 237 237 unset($GLOBALS['wp_taxonomies'][$tax]); 238 _unregister_post_type( $post_type );238 unregister_post_type( $post_type ); 239 239 240 240 } 241 241 … … class Tests_Taxonomy extends WP_UnitTestCase { 351 351 ) ); 352 352 353 353 $this->assertSame( array(), get_ancestors( $t, 'wptests_tax' ) ); 354 _unregister_taxonomy( 'wptests_tax' );354 unregister_taxonomy( 'wptests_tax' ); 355 355 } 356 356 357 357 public function test_get_ancestors_taxonomy() { … … class Tests_Taxonomy extends WP_UnitTestCase { 375 375 ) ); 376 376 377 377 $this->assertEqualSets( array( $t2, $t1 ), get_ancestors( $t3, 'wptests_tax' ) ); 378 _unregister_taxonomy( 'wptests_tax' );378 unregister_taxonomy( 'wptests_tax' ); 379 379 } 380 380 381 381 public function test_get_ancestors_post_type_non_hierarchical() { … … class Tests_Taxonomy extends WP_UnitTestCase { 408 408 ) ); 409 409 410 410 $this->assertEqualSets( array( $p2, $p1 ), get_ancestors( $p3, 'wptests_pt' ) ); 411 _unregister_post_type( 'wptests_pt' );411 unregister_post_type( 'wptests_pt' ); 412 412 } 413 413 414 414 /** … … class Tests_Taxonomy extends WP_UnitTestCase { 440 440 $this->assertEqualSets( array( $p1 ), get_ancestors( $p2, 'wptests_conflict', 'post_type' ) ); 441 441 $this->assertEqualSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict', 'taxonomy' ) ); 442 442 $this->assertEqualSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict' ) ); 443 _unregister_post_type( 'wptests_pt' );443 unregister_post_type( 'wptests_pt' ); 444 444 } 445 445 446 446 /** … … class Tests_Taxonomy extends WP_UnitTestCase { 517 517 518 518 $this->assertFalse( is_tax( 'wptests_tax' ) ); 519 519 } 520 521 /** 522 * @ticket 35227 523 */ 524 public function test_unregister_taxonomy() { 525 register_taxonomy( 'foo', 'post' ); 526 $this->assertTrue( unregister_taxonomy( 'foo' ) ); 527 } 528 529 /** 530 * @ticket 35227 531 */ 532 public function test_unregister_taxonomy_unknown_taxonomy() { 533 $this->assertFalse( unregister_taxonomy( 'foo' ) ); 534 } 535 536 /** 537 * @ticket 35227 538 */ 539 public function test_unregister_taxonomy_twice() { 540 register_taxonomy( 'foo', 'post' ); 541 $this->assertTrue( unregister_taxonomy( 'foo' ) ); 542 $this->assertFalse( unregister_taxonomy( 'foo' ) ); 543 } 544 545 /** 546 * @ticket 35227 547 */ 548 public function test_unregister_taxonomy_disallow_builtin_taxonomy() { 549 $this->assertFalse( unregister_taxonomy( 'post_tag' ) ); 550 $this->assertFalse( unregister_taxonomy( 'category' ) ); 551 } 552 553 /** 554 * @ticket 35227 555 */ 556 public function test_unregister_taxonomy_removes_query_vars() { 557 global $wp; 558 559 register_taxonomy( 'foo', 'post', array( 'query_var' => 'bar' ) ); 560 561 $this->assertInternalType( 'int', array_search( 'bar', $wp->public_query_vars ) ); 562 $this->assertTrue( unregister_taxonomy( 'foo' ) ); 563 $this->assertFalse( array_search( 'bar', $wp->public_query_vars ) ); 564 } 565 566 /** 567 * @ticket 35227 568 */ 569 public function test_unregister_taxonomy_removes_rewrite_rules() { 570 $this->set_permalink_structure( '/%postname%' ); 571 572 global $wp_rewrite; 573 574 register_taxonomy( 'foo', 'post', array( 'query_var' => 'bar' ) ); 575 576 $count_before = count( $wp_rewrite->rewritereplace ); 577 578 $this->assertInternalType( 'int', array_search( '%foo%', $wp_rewrite->rewritecode ) ); 579 $this->assertInternalType( 'int', array_search( 'bar=', $wp_rewrite->queryreplace ) ); 580 $this->assertTrue( unregister_taxonomy( 'foo' ) ); 581 $this->assertFalse( array_search( '%foo%', $wp_rewrite->rewritecode ) ); 582 $this->assertFalse( array_search( 'bar=', $wp_rewrite->queryreplace ) ); 583 $this->assertSame( --$count_before, count( $wp_rewrite->rewritereplace ) ); // Array was reduced by one value. 584 } 585 586 /** 587 * @ticket 35227 588 */ 589 public function test_unregister_taxonomy_removes_taxonomy_from_global() { 590 global $wp_taxonomies; 591 592 register_taxonomy( 'foo', 'post' ); 593 594 $this->assertInternalType( 'object', $wp_taxonomies['foo'] ); 595 $this->assertInternalType( 'object', get_taxonomy( 'foo' ) ); 596 597 $this->assertTrue( unregister_taxonomy( 'foo' ) ); 598 599 $this->assertFalse( isset( $wp_taxonomies['foo'] ) ); 600 $this->assertFalse( get_taxonomy( 'foo' ) ); 601 } 602 603 /** 604 * @ticket 35227 605 */ 606 public function test_unregister_taxonomy_removes_meta_box_callback() { 607 global $wp_filter; 608 609 register_taxonomy( 'foo', 'post' ); 610 611 $this->assertSame( 1, count( $wp_filter['wp_ajax_add-foo'] ) ); 612 $this->assertTrue( unregister_taxonomy( 'foo' ) ); 613 $this->assertSame( array(), $wp_filter['wp_ajax_add-foo'] ); 614 } 520 615 } -
tests/phpunit/tests/term.php
diff --git tests/phpunit/tests/term.php tests/phpunit/tests/term.php index 1fdbd14..d206431 100644
class Tests_Term extends WP_UnitTestCase { 243 243 $this->assertNotEmpty( $added2 ); 244 244 $this->assertEqualSets( array( $t1, $t2 ), wp_get_object_terms( $p, 'wptests_tax', array( 'fields' => 'ids' ) ) ); 245 245 246 _unregister_taxonomy( 'wptests_tax' );246 unregister_taxonomy( 'wptests_tax' ); 247 247 } 248 248 249 249 public function test_wp_set_object_terms_append_false() { … … class Tests_Term extends WP_UnitTestCase { 264 264 $this->assertNotEmpty( $added2 ); 265 265 $this->assertEqualSets( array( $t2 ), wp_get_object_terms( $p, 'wptests_tax', array( 'fields' => 'ids' ) ) ); 266 266 267 _unregister_taxonomy( 'wptests_tax' );267 unregister_taxonomy( 'wptests_tax' ); 268 268 } 269 269 270 270 public function test_wp_set_object_terms_append_default_to_false() { … … class Tests_Term extends WP_UnitTestCase { 285 285 $this->assertNotEmpty( $added2 ); 286 286 $this->assertEqualSets( array( $t2 ), wp_get_object_terms( $p, 'wptests_tax', array( 'fields' => 'ids' ) ) ); 287 287 288 _unregister_taxonomy( 'wptests_tax' );288 unregister_taxonomy( 'wptests_tax' ); 289 289 } 290 290 291 291 function test_change_object_terms_by_id() { -
tests/phpunit/tests/term/cache.php
diff --git tests/phpunit/tests/term/cache.php tests/phpunit/tests/term/cache.php index 828917a..bf10fab 100644
class Tests_Term_Cache extends WP_UnitTestCase { 91 91 } 92 92 } 93 93 94 _unregister_taxonomy( $tax );94 unregister_taxonomy( $tax ); 95 95 } 96 96 97 97 public function test_get_term_should_update_term_cache_when_passed_an_object() { … … class Tests_Term_Cache extends WP_UnitTestCase { 198 198 199 199 $this->assertSame( $num_queries, $wpdb->num_queries ); 200 200 201 _unregister_taxonomy( 'wptests_tax' );201 unregister_taxonomy( 'wptests_tax' ); 202 202 } 203 203 } -
tests/phpunit/tests/term/getTerm.php
diff --git tests/phpunit/tests/term/getTerm.php tests/phpunit/tests/term/getTerm.php index 7aeb3f3..fac495e 100644
class Tests_Term_GetTerm extends WP_UnitTestCase { 211 211 public function test_should_return_error_when_only_matching_term_is_in_an_invalid_taxonomy() { 212 212 $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); 213 213 214 _unregister_taxonomy( 'wptests_tax' );214 unregister_taxonomy( 'wptests_tax' ); 215 215 216 216 $found = get_term( $t ); 217 217 $this->assertWPError( $found ); … … class Tests_Term_GetTerm extends WP_UnitTestCase { 224 224 public function test_term_should_be_returned_when_id_is_shared_only_with_invalid_taxonomies() { 225 225 $terms = $this->generate_shared_terms(); 226 226 227 _unregister_taxonomy( 'wptests_tax' );227 unregister_taxonomy( 'wptests_tax' ); 228 228 229 229 $found = get_term( $terms[1]['term_id'] ); 230 230 $this->assertInstanceOf( 'WP_Term', $found ); -
tests/phpunit/tests/term/getTerms.php
diff --git tests/phpunit/tests/term/getTerms.php tests/phpunit/tests/term/getTerms.php index bcd3485..d771aaa 100644
class Tests_Term_getTerms extends WP_UnitTestCase { 192 192 193 193 $this->assertEquals( array( $terms[1] ), wp_list_pluck( $found, 'term_id' ) ); 194 194 195 _unregister_taxonomy( 'wptests_tax' );195 unregister_taxonomy( 'wptests_tax' ); 196 196 } 197 197 198 198 /** … … class Tests_Term_getTerms extends WP_UnitTestCase { 336 336 $this->assertEquals( 1, count( $terms ) ); 337 337 $this->assertEquals( array( 'Cheese' ), wp_list_pluck( $terms, 'name' ) ); 338 338 339 _unregister_taxonomy( $tax );339 unregister_taxonomy( $tax ); 340 340 } 341 341 342 342 /** … … class Tests_Term_getTerms extends WP_UnitTestCase { 360 360 $this->assertEquals( 1, count( $terms ) ); 361 361 $this->assertEquals( array( 'term1' ), wp_list_pluck( $terms, 'name' ) ); 362 362 363 _unregister_taxonomy( $tax );363 unregister_taxonomy( $tax ); 364 364 } 365 365 366 366 /** … … class Tests_Term_getTerms extends WP_UnitTestCase { 697 697 $terms['grandchild1'], 698 698 ); 699 699 700 _unregister_taxonomy( 'hierarchical_fields' );700 unregister_taxonomy( 'hierarchical_fields' ); 701 701 702 702 $this->assertEqualSets( $expected, $found ); 703 703 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 720 720 $terms['child1'], 721 721 ); 722 722 723 _unregister_taxonomy( 'hierarchical_fields' );723 unregister_taxonomy( 'hierarchical_fields' ); 724 724 725 725 $this->assertEqualSets( $expected, $found ); 726 726 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 743 743 $terms['child1'], 744 744 ); 745 745 746 _unregister_taxonomy( 'hierarchical_fields' );746 unregister_taxonomy( 'hierarchical_fields' ); 747 747 748 748 $this->assertEqualSets( $expected, $found ); 749 749 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 768 768 'Grandchild 1', 769 769 ); 770 770 771 _unregister_taxonomy( 'hierarchical_fields' );771 unregister_taxonomy( 'hierarchical_fields' ); 772 772 773 773 $this->assertEqualSets( $expected, $found ); 774 774 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 791 791 'Child 1', 792 792 ); 793 793 794 _unregister_taxonomy( 'hierarchical_fields' );794 unregister_taxonomy( 'hierarchical_fields' ); 795 795 796 796 $this->assertEqualSets( $expected, $found ); 797 797 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 814 814 'Child 1', 815 815 ); 816 816 817 _unregister_taxonomy( 'hierarchical_fields' );817 unregister_taxonomy( 'hierarchical_fields' ); 818 818 819 819 $this->assertEqualSets( $expected, $found ); 820 820 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 831 831 'fields' => 'count', 832 832 ) ); 833 833 834 _unregister_taxonomy( 'hierarchical_fields' );834 unregister_taxonomy( 'hierarchical_fields' ); 835 835 836 836 $this->assertEquals( 5, $found ); 837 837 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 848 848 'fields' => 'count', 849 849 ) ); 850 850 851 _unregister_taxonomy( 'hierarchical_fields' );851 unregister_taxonomy( 'hierarchical_fields' ); 852 852 853 853 // When using 'fields=count', 'hierarchical' is forced to false. 854 854 $this->assertEquals( 2, $found ); … … class Tests_Term_getTerms extends WP_UnitTestCase { 867 867 'hierarchical' => false, 868 868 ) ); 869 869 870 _unregister_taxonomy( 'hierarchical_fields' );870 unregister_taxonomy( 'hierarchical_fields' ); 871 871 872 872 $this->assertEquals( 2, $found ); 873 873 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 892 892 $terms['grandchild1'] => $terms['child1'], 893 893 ); 894 894 895 _unregister_taxonomy( 'hierarchical_fields' );895 unregister_taxonomy( 'hierarchical_fields' ); 896 896 897 897 $this->assertEqualSetsWithIndex( $expected, $found ); 898 898 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 915 915 $terms['child1'] => $terms['parent1'], 916 916 ); 917 917 918 _unregister_taxonomy( 'hierarchical_fields' );918 unregister_taxonomy( 'hierarchical_fields' ); 919 919 920 920 $this->assertEqualSetsWithIndex( $expected, $found ); 921 921 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 938 938 $terms['child1'] => $terms['parent1'], 939 939 ); 940 940 941 _unregister_taxonomy( 'hierarchical_fields' );941 unregister_taxonomy( 'hierarchical_fields' ); 942 942 943 943 $this->assertEqualSetsWithIndex( $expected, $found ); 944 944 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 963 963 $terms['grandchild1'] => 'grandchild-1', 964 964 ); 965 965 966 _unregister_taxonomy( 'hierarchical_fields' );966 unregister_taxonomy( 'hierarchical_fields' ); 967 967 968 968 $this->assertEqualSetsWithIndex( $expected, $found ); 969 969 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 989 989 $terms['child1'] => 'child-1', 990 990 ); 991 991 992 _unregister_taxonomy( 'hierarchical_fields' );992 unregister_taxonomy( 'hierarchical_fields' ); 993 993 994 994 $this->assertEqualSetsWithIndex( $expected, $found ); 995 995 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 1012 1012 $terms['child1'] => 'child-1', 1013 1013 ); 1014 1014 1015 _unregister_taxonomy( 'hierarchical_fields' );1015 unregister_taxonomy( 'hierarchical_fields' ); 1016 1016 1017 1017 $this->assertEqualSetsWithIndex( $expected, $found ); 1018 1018 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 1037 1037 $terms['grandchild1'] => 'Grandchild 1', 1038 1038 ); 1039 1039 1040 _unregister_taxonomy( 'hierarchical_fields' );1040 unregister_taxonomy( 'hierarchical_fields' ); 1041 1041 1042 1042 $this->assertEqualSetsWithIndex( $expected, $found ); 1043 1043 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 1063 1063 $terms['child1'] => 'Child 1', 1064 1064 ); 1065 1065 1066 _unregister_taxonomy( 'hierarchical_fields' );1066 unregister_taxonomy( 'hierarchical_fields' ); 1067 1067 1068 1068 $this->assertEqualSetsWithIndex( $expected, $found ); 1069 1069 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 1086 1086 $terms['child1'] => 'Child 1', 1087 1087 ); 1088 1088 1089 _unregister_taxonomy( 'hierarchical_fields' );1089 unregister_taxonomy( 'hierarchical_fields' ); 1090 1090 1091 1091 $this->assertEqualSetsWithIndex( $expected, $found ); 1092 1092 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 1152 1152 'hide_empty' => false, 1153 1153 ) ); 1154 1154 1155 _unregister_taxonomy( 'wptests_tax' );1155 unregister_taxonomy( 'wptests_tax' ); 1156 1156 1157 1157 $this->assertEquals( array( $t4, $t1, $t2 ), $found ); 1158 1158 } … … class Tests_Term_getTerms extends WP_UnitTestCase { 1175 1175 'hide_empty' => false, 1176 1176 ) ); 1177 1177 1178 _unregister_taxonomy( 'wptests_tax' );1178 unregister_taxonomy( 'wptests_tax' ); 1179 1179 1180 1180 $this->assertEquals( array( $t2, $t1, $t4, $t3 ), $found ); 1181 1181 } -
tests/phpunit/tests/term/isObjectInTerm.php
diff --git tests/phpunit/tests/term/isObjectInTerm.php tests/phpunit/tests/term/isObjectInTerm.php index 0da95ab..ef8a87c 100644
class Tests_IsObjectInTerm extends WP_UnitTestCase { 16 16 $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( $t1, $t2 ) ) ); 17 17 $this->assertFalse( is_object_in_term( $posts[1], 'wptests_tax', array( $t1, $t2 ) ) ); 18 18 19 _unregister_taxonomy( 'wptests_tax', 'post' );19 unregister_taxonomy( 'wptests_tax', 'post' ); 20 20 } 21 21 22 22 public function test_terms_are_strings_and_match_term_id() { … … class Tests_IsObjectInTerm extends WP_UnitTestCase { 34 34 $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( $t1_str, $t2_str ) ) ); 35 35 $this->assertFalse( is_object_in_term( $posts[1], 'wptests_tax', array( $t1_str, $t2_str ) ) ); 36 36 37 _unregister_taxonomy( 'wptests_tax', 'post' );37 unregister_taxonomy( 'wptests_tax', 'post' ); 38 38 } 39 39 40 40 public function test_terms_are_strings_and_match_term_name() { … … class Tests_IsObjectInTerm extends WP_UnitTestCase { 49 49 $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( 'Foo', 'Bar' ) ) ); 50 50 $this->assertFalse( is_object_in_term( $posts[1], 'wptests_tax', array( 'Foo', 'Bar' ) ) ); 51 51 52 _unregister_taxonomy( 'wptests_tax', 'post' );52 unregister_taxonomy( 'wptests_tax', 'post' ); 53 53 } 54 54 55 55 public function test_terms_are_strings_and_match_term_slug() { … … class Tests_IsObjectInTerm extends WP_UnitTestCase { 64 64 $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( 'foo', 'bar' ) ) ); 65 65 $this->assertFalse( is_object_in_term( $posts[1], 'wptests_tax', array( 'foo', 'bar' ) ) ); 66 66 67 _unregister_taxonomy( 'wptests_tax', 'post' );67 unregister_taxonomy( 'wptests_tax', 'post' ); 68 68 } 69 69 70 70 public function test_terms_contain_strings_and_ints_and_match_term_id_as_int() { … … class Tests_IsObjectInTerm extends WP_UnitTestCase { 79 79 $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( $t1, 'bar' ) ) ); 80 80 $this->assertFalse( is_object_in_term( $posts[1], 'wptests_tax', array( $t1, 'bar' ) ) ); 81 81 82 _unregister_taxonomy( 'wptests_tax', 'post' );82 unregister_taxonomy( 'wptests_tax', 'post' ); 83 83 } 84 84 85 85 /** -
tests/phpunit/tests/term/query.php
diff --git tests/phpunit/tests/term/query.php tests/phpunit/tests/term/query.php index 2b717c7..597d964 100644
class Tests_Tax_Query extends WP_UnitTestCase { 275 275 // Only one JOIN is required with OR + IN. 276 276 $this->assertSame( 1, substr_count( $sql['join'], 'JOIN' ) ); 277 277 278 _unregister_taxonomy( 'wptests_tax' );278 unregister_taxonomy( 'wptests_tax' ); 279 279 } 280 280 281 281 /** … … class Tests_Tax_Query extends WP_UnitTestCase { 318 318 319 319 $this->assertSame( 3, substr_count( $sql['join'], 'JOIN' ) ); 320 320 321 _unregister_taxonomy( 'wptests_tax' );321 unregister_taxonomy( 'wptests_tax' ); 322 322 } 323 323 324 324 /** … … class Tests_Tax_Query extends WP_UnitTestCase { 364 364 365 365 $this->assertSame( 2, substr_count( $sql['join'], 'JOIN' ) ); 366 366 367 _unregister_taxonomy( 'wptests_tax' );367 unregister_taxonomy( 'wptests_tax' ); 368 368 } 369 369 370 370 /** … … class Tests_Tax_Query extends WP_UnitTestCase { 391 391 392 392 $this->assertSame( $expected, $tq->get_sql( $wpdb->posts, 'ID' ) ); 393 393 394 _unregister_taxonomy( 'wptests_tax' );394 unregister_taxonomy( 'wptests_tax' ); 395 395 } 396 396 397 397 /** … … class Tests_Tax_Query extends WP_UnitTestCase { 418 418 419 419 $this->assertSame( $expected, $tq->get_sql( $wpdb->posts, 'ID' ) ); 420 420 421 _unregister_taxonomy( 'wptests_tax' );421 unregister_taxonomy( 'wptests_tax' ); 422 422 } 423 423 } -
tests/phpunit/tests/term/termExists.php
diff --git tests/phpunit/tests/term/termExists.php tests/phpunit/tests/term/termExists.php index b00b6e8..5c8e71e 100644
class Tests_TermExists extends WP_UnitTestCase { 96 96 97 97 $found = term_exists( 'child-term', 'foo', $parent_term ); 98 98 99 _unregister_taxonomy( 'foo' );99 unregister_taxonomy( 'foo' ); 100 100 101 101 $this->assertInternalType( 'array', $found ); 102 102 $this->assertEquals( $t, $found['term_id'] ); … … class Tests_TermExists extends WP_UnitTestCase { 122 122 123 123 $found = term_exists( 'child-term', 'foo', 0 ); 124 124 125 _unregister_taxonomy( 'foo' );125 unregister_taxonomy( 'foo' ); 126 126 127 127 $this->assertSame( null, $found['term_id'] ); 128 128 } … … class Tests_TermExists extends WP_UnitTestCase { 144 144 145 145 $found = term_exists( 'Child Term', 'foo', $parent_term ); 146 146 147 _unregister_taxonomy( 'foo' );147 unregister_taxonomy( 'foo' ); 148 148 149 149 $this->assertInternalType( 'array', $found ); 150 150 $this->assertEquals( $t, $found['term_id'] ); … … class Tests_TermExists extends WP_UnitTestCase { 160 160 161 161 $found = term_exists( 'kewl-dudez', 'foo' ); 162 162 163 _unregister_taxonomy( 'foo' );163 unregister_taxonomy( 'foo' ); 164 164 165 165 $this->assertInternalType( 'array', $found ); 166 166 $this->assertEquals( $t, $found['term_id'] ); … … class Tests_TermExists extends WP_UnitTestCase { 176 176 177 177 $found = term_exists( 'Kewl Dudez', 'foo' ); 178 178 179 _unregister_taxonomy( 'foo' );179 unregister_taxonomy( 'foo' ); 180 180 181 181 $this->assertInternalType( 'array', $found ); 182 182 $this->assertEquals( $t, $found['term_id'] ); … … class Tests_TermExists extends WP_UnitTestCase { 192 192 193 193 $found = term_exists( 'juicy-fruit' ); 194 194 195 _unregister_taxonomy( 'foo' );195 unregister_taxonomy( 'foo' ); 196 196 197 197 $this->assertInternalType( 'string', $found ); 198 198 $this->assertEquals( $t, $found ); … … class Tests_TermExists extends WP_UnitTestCase { 208 208 209 209 $found = term_exists( 'Juicy Fruit' ); 210 210 211 _unregister_taxonomy( 'foo' );211 unregister_taxonomy( 'foo' ); 212 212 213 213 $this->assertInternalType( 'string', $found ); 214 214 $this->assertEquals( $t, $found ); … … class Tests_TermExists extends WP_UnitTestCase { 226 226 227 227 // clean up 228 228 $this->assertTrue( wp_delete_term( $t['term_id'], 'wptests_tax' ) ); 229 _unregister_taxonomy( 'wptests_tax' );229 unregister_taxonomy( 'wptests_tax' ); 230 230 } 231 231 232 232 function test_term_exists_unknown() { -
tests/phpunit/tests/term/wpInsertTerm.php
diff --git tests/phpunit/tests/term/wpInsertTerm.php tests/phpunit/tests/term/wpInsertTerm.php index c3dea31..633dd48 100644
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 89 89 $found = wp_insert_term( 'Let\\\'s all say \\"Hooray\\" for WordPress taxonomy', 'wptests_tax' ); 90 90 91 91 $term = get_term( $found['term_id'], 'wptests_tax' ); 92 _unregister_taxonomy( 'wptests_tax' );92 unregister_taxonomy( 'wptests_tax' ); 93 93 94 94 $this->assertSame( 'Let\'s all say "Hooray" for WordPress taxonomy', $term->name ); 95 95 } … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 101 101 ) ); 102 102 103 103 $term = get_term( $found['term_id'], 'wptests_tax' ); 104 _unregister_taxonomy( 'wptests_tax' );104 unregister_taxonomy( 'wptests_tax' ); 105 105 106 106 $this->assertSame( 'Let\'s all say "Hooray" for WordPress taxonomy', $term->description ); 107 107 } … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 113 113 ) ); 114 114 115 115 $term = get_term( $found['term_id'], 'wptests_tax' ); 116 _unregister_taxonomy( 'wptests_tax' );116 unregister_taxonomy( 'wptests_tax' ); 117 117 118 118 // 'foo1' is cast to 0 in sanitize_term(). 119 119 $this->assertSame( 0, $term->parent ); … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 126 126 ) ); 127 127 128 128 $term = get_term( $found['term_id'], 'wptests_tax' ); 129 _unregister_taxonomy( 'wptests_tax' );129 unregister_taxonomy( 'wptests_tax' ); 130 130 131 131 $this->assertSame( 'quality', $term->slug ); 132 132 … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 139 139 ) ); 140 140 141 141 $term = get_term( $found['term_id'], 'wptests_tax' ); 142 _unregister_taxonomy( 'wptests_tax' );142 unregister_taxonomy( 'wptests_tax' ); 143 143 144 144 $this->assertSame( 'quality', $term->slug ); 145 145 } … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 151 151 ) ); 152 152 153 153 $term = get_term( $found['term_id'], 'wptests_tax' ); 154 _unregister_taxonomy( 'wptests_tax' );154 unregister_taxonomy( 'wptests_tax' ); 155 155 156 156 $this->assertSame( 'quality', $term->slug ); 157 157 } … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 434 434 $created_term = get_term( $created['term_id'], 'wptests_tax' ); 435 435 $this->assertSame( 'foo-2', $created_term->slug ); 436 436 437 _unregister_taxonomy( 'wptests_tax', 'post' );437 unregister_taxonomy( 'wptests_tax', 'post' ); 438 438 } 439 439 440 440 /** … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 461 461 462 462 $this->assertSame( 'foo', $new_term->slug ); 463 463 464 _unregister_taxonomy( 'wptests_tax', 'post' );464 unregister_taxonomy( 'wptests_tax', 'post' ); 465 465 } 466 466 467 467 /** … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 496 496 $this->assertSame( 'foo-2', $new_term->slug ); 497 497 $this->assertNotEquals( $new_term->term_id, $term->term_id ); 498 498 499 _unregister_taxonomy( 'wptests_tax', 'post' );499 unregister_taxonomy( 'wptests_tax', 'post' ); 500 500 } 501 501 502 502 public function test_wp_insert_term_alias_of_no_term_group() { … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 514 514 $updated_term_1 = get_term( $term_1->term_id, 'wptests_tax' ); 515 515 516 516 $term = get_term( $created_term_ids['term_id'], 'wptests_tax' ); 517 _unregister_taxonomy( 'wptests_tax' );517 unregister_taxonomy( 'wptests_tax' ); 518 518 519 519 $this->assertSame( 0, $term_1->term_group ); 520 520 $this->assertNotEmpty( $created_term->term_group ); … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 538 538 'alias_of' => $term_2->slug, 539 539 ) ); 540 540 $created_term = get_term( $created_term_ids['term_id'], 'wptests_tax' ); 541 _unregister_taxonomy( 'wptests_tax' );541 unregister_taxonomy( 'wptests_tax' ); 542 542 543 543 $this->assertNotEmpty( $created_term->term_group ); 544 544 $this->assertSame( $created_term->term_group, $term_2->term_group ); … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 550 550 'alias_of' => 'foo', 551 551 ) ); 552 552 $created_term = get_term( $created_term_ids['term_id'], 'wptests_tax' ); 553 _unregister_taxonomy( 'wptests_tax' );553 unregister_taxonomy( 'wptests_tax' ); 554 554 555 555 $this->assertSame( 0, $created_term->term_group ); 556 556 } … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 576 576 $term_by_slug = get_term_by( 'slug', 'foo', 'wptests_tax' ); 577 577 $term_by_ttid = get_term_by( 'term_taxonomy_id', $found['term_taxonomy_id'], 'wptests_tax' ); 578 578 579 _unregister_taxonomy( 'wptests_tax' );579 unregister_taxonomy( 'wptests_tax' ); 580 580 581 581 $this->assertInternalType( 'array', $found ); 582 582 $this->assertNotEmpty( $found['term_id'] ); … … class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 607 607 $found = wp_insert_term( 'foo', 'wptests_tax', array( 608 608 'parent' => $t, 609 609 ) ); 610 _unregister_taxonomy( 'wptests_tax' );610 unregister_taxonomy( 'wptests_tax' ); 611 611 612 612 $this->assertSame( false, wp_cache_get( 'all_ids', 'wptests_tax' ) ); 613 613 $this->assertSame( false, wp_cache_get( 'get', 'wptests_tax' ) ); -
tests/phpunit/tests/term/wpUpdateTerm.php
diff --git tests/phpunit/tests/term/wpUpdateTerm.php tests/phpunit/tests/term/wpUpdateTerm.php index 4d9d17b..f7eea70 100644
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 29 29 ) ); 30 30 31 31 $term = get_term( $found['term_id'], 'wptests_tax' ); 32 _unregister_taxonomy( 'wptests_tax' );32 unregister_taxonomy( 'wptests_tax' ); 33 33 34 34 $this->assertSame( 'Let\'s all say "Hooray" for WordPress taxonomy', $term->name ); 35 35 } … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 45 45 ) ); 46 46 47 47 $term = get_term( $found['term_id'], 'wptests_tax' ); 48 _unregister_taxonomy( 'wptests_tax' );48 unregister_taxonomy( 'wptests_tax' ); 49 49 50 50 $this->assertSame( 'Let\'s all say "Hooray" for WordPress taxonomy', $term->description ); 51 51 } … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 62 62 63 63 $this->assertTrue( is_wp_error( $found ) ); 64 64 $this->assertSame( 'empty_term_name', $found->get_error_code() ); 65 _unregister_taxonomy( 'wptests_tax' );65 unregister_taxonomy( 'wptests_tax' ); 66 66 } 67 67 68 68 /** … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 89 89 90 90 $term = get_term( $t, 'wptests_tax' ); 91 91 $this->assertEquals( 0, $term->parent ); 92 _unregister_taxonomy( 'wptests_tax' );92 unregister_taxonomy( 'wptests_tax' ); 93 93 } 94 94 95 95 public function test_wp_update_term_slug_empty_string_while_not_updating_name() { … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 105 105 106 106 $term = get_term( $t, 'wptests_tax' ); 107 107 $this->assertSame( 'foo-bar', $term->slug ); 108 _unregister_taxonomy( 'wptests_tax' );108 unregister_taxonomy( 'wptests_tax' ); 109 109 } 110 110 111 111 public function test_wp_update_term_slug_empty_string_while_updating_name() { … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 121 121 122 122 $term = get_term( $t, 'wptests_tax' ); 123 123 $this->assertSame( 'foo-bar', $term->slug ); 124 _unregister_taxonomy( 'wptests_tax' );124 unregister_taxonomy( 'wptests_tax' ); 125 125 } 126 126 127 127 public function test_wp_update_term_slug_set_slug() { … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 136 136 137 137 $term = get_term( $t, 'wptests_tax' ); 138 138 $this->assertSame( 'foo-bar', $term->slug ); 139 _unregister_taxonomy( 'wptests_tax' );139 unregister_taxonomy( 'wptests_tax' ); 140 140 } 141 141 142 142 /** … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 314 314 $created_term = get_term( $created_term_ids['term_id'], 'wptests_tax' ); 315 315 316 316 $updated_term_1 = get_term( $t1, 'wptests_tax' ); 317 _unregister_taxonomy( 'wptests_tax' );317 unregister_taxonomy( 'wptests_tax' ); 318 318 319 319 $this->assertSame( 0, $term_1->term_group ); 320 320 $this->assertNotEmpty( $created_term->term_group ); … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 339 339 'alias_of' => $term_2->slug, 340 340 ) ); 341 341 $created_term = get_term( $created_term_ids['term_id'], 'wptests_tax' ); 342 _unregister_taxonomy( 'wptests_tax' );342 unregister_taxonomy( 'wptests_tax' ); 343 343 344 344 $this->assertNotEmpty( $created_term->term_group ); 345 345 $this->assertSame( $created_term->term_group, $term_2->term_group ); … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 352 352 'alias_of' => 'bar', 353 353 ) ); 354 354 $created_term = get_term( $created_term_ids['term_id'], 'wptests_tax' ); 355 _unregister_taxonomy( 'wptests_tax' );355 unregister_taxonomy( 'wptests_tax' ); 356 356 357 357 $this->assertSame( 0, $created_term->term_group ); 358 358 } … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 372 372 373 373 $this->assertSame( $t, $found['term_id'] ); 374 374 $this->assertSame( 'foo', $term->slug ); 375 _unregister_taxonomy( 'wptests_tax' );375 unregister_taxonomy( 'wptests_tax' ); 376 376 } 377 377 378 378 public function test_wp_update_term_duplicate_slug_generated_due_to_empty_slug_param() { … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 395 395 396 396 $this->assertSame( $t2, $found['term_id'] ); 397 397 $this->assertSame( 'foo-bar-2', $term->slug ); 398 _unregister_taxonomy( 'wptests_tax' );398 unregister_taxonomy( 'wptests_tax' ); 399 399 } 400 400 401 401 public function test_wp_update_term_duplicate_slug_with_changed_parent() { … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 423 423 424 424 $this->assertSame( $t2, $found['term_id'] ); 425 425 $this->assertSame( 'foo-bar-' . $parent_term->slug, $term->slug ); 426 _unregister_taxonomy( 'wptests_tax' );426 unregister_taxonomy( 'wptests_tax' ); 427 427 } 428 428 429 429 public function test_wp_update_term_duplicate_slug_failure() { … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 446 446 $this->assertWPError( $found ); 447 447 $this->assertSame( 'duplicate_term_slug', $found->get_error_code() ); 448 448 $this->assertSame( 'my-old-slug', $term->slug ); 449 _unregister_taxonomy( 'wptests_tax' );449 unregister_taxonomy( 'wptests_tax' ); 450 450 } 451 451 452 452 public function test_wp_update_term_should_return_term_id_and_term_taxonomy_id() { … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 462 462 $term_by_slug = get_term_by( 'slug', 'foo', 'wptests_tax' ); 463 463 $term_by_ttid = get_term_by( 'term_taxonomy_id', $found['term_taxonomy_id'], 'wptests_tax' ); 464 464 465 _unregister_taxonomy( 'wptests_tax' );465 unregister_taxonomy( 'wptests_tax' ); 466 466 467 467 $this->assertInternalType( 'array', $found ); 468 468 $this->assertNotEmpty( $found['term_id'] ); … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 546 546 $found = wp_update_term( $t1, 'wptests_tax', array( 547 547 'parent' => $t2, 548 548 ) ); 549 _unregister_taxonomy( 'wptests_tax' );549 unregister_taxonomy( 'wptests_tax' ); 550 550 551 551 $this->assertSame( false, wp_cache_get( 'all_ids', 'wptests_tax' ) ); 552 552 $this->assertSame( false, wp_cache_get( 'get', 'wptests_tax' ) ); … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 585 585 586 586 $this->assertSame( 'foo', $t2_term->slug ); 587 587 588 _unregister_taxonomy( 'wptests_tax' );588 unregister_taxonomy( 'wptests_tax' ); 589 589 } 590 590 591 591 /** … … class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 623 623 624 624 $this->assertSame( 'foo', $t3_term->slug ); 625 625 626 _unregister_taxonomy( 'wptests_tax' );626 unregister_taxonomy( 'wptests_tax' ); 627 627 } 628 628 629 629 /**