Changeset 748 in tests
- Timestamp:
- 06/28/2012 08:05:14 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_includes_taxonomy.php
r574 r748 363 363 $this->assertEquals( $initial_count, wp_count_terms('category') ); 364 364 } 365 366 function test_wp_unique_term_slug() { 367 // set up test data 368 $a = wp_insert_term( 'parent', $this->taxonomy ); 369 $b = wp_insert_term( 'child', $this->taxonomy, array( 'parent' => $a['term_id'] ) ); 370 $c = wp_insert_term( 'neighbor', $this->taxonomy ); 371 $d = wp_insert_term( 'pet', $this->taxonomy, array( 'parent' => $c['term_id'] ) ); 372 373 $a_term = get_term( $a['term_id'], $this->taxonomy ); 374 $b_term = get_term( $b['term_id'], $this->taxonomy ); 375 $d_term = get_term( $d['term_id'], $this->taxonomy ); 376 377 // a unique slug gets unchanged 378 $this->assertEquals( 'unique-term', wp_unique_term_slug( 'unique-term', $c_term ) ); 379 380 // a non-hierarchicial dupe gets suffixed with "-#" 381 $this->assertEquals( 'parent-2', wp_unique_term_slug( 'parent', $c_term ) ); 382 383 // a hierarchical dupe initially gets suffixed with its parent term 384 $this->assertEquals( 'child-neighbor', wp_unique_term_slug( 'child', $d_term ) ); 385 386 // a hierarchical dupe whose parent already contains the {term}-{parent term} 387 // term gets suffixed with parent term name and then '-#' 388 $e = wp_insert_term( 'child-neighbor', $this->taxonomy, array( 'parent' => $c['term_id'] ) ); 389 $this->assertEquals( 'child-neighbor-2', wp_unique_term_slug( 'child', $d_term ) ); 390 391 // clean up 392 foreach ( array( $a, $b, $c, $d, $e ) as $t ) 393 $this->assertTrue( wp_delete_term( $t['term_id'], $this->taxonomy ) ); 394 } 365 395 } 366 396
Note: See TracChangeset
for help on using the changeset viewer.