Changeset 32507
- Timestamp:
- 05/15/2015 08:37:51 PM (10 years ago)
- Location:
- trunk/tests/phpunit/tests
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term.php
r31812 r32507 472 472 } 473 473 474 function test_wp_unique_term_slug() {475 // set up test data476 $a = wp_insert_term( 'parent', $this->taxonomy );477 $this->assertInternalType( 'array', $a );478 $b = wp_insert_term( 'child', $this->taxonomy, array( 'parent' => $a['term_id'] ) );479 $this->assertInternalType( 'array', $b );480 $c = wp_insert_term( 'neighbor', $this->taxonomy );481 $this->assertInternalType( 'array', $c );482 $d = wp_insert_term( 'pet', $this->taxonomy, array( 'parent' => $c['term_id'] ) );483 $this->assertInternalType( 'array', $c );484 485 $a_term = get_term( $a['term_id'], $this->taxonomy );486 $b_term = get_term( $b['term_id'], $this->taxonomy );487 $c_term = get_term( $c['term_id'], $this->taxonomy );488 $d_term = get_term( $d['term_id'], $this->taxonomy );489 490 // a unique slug gets unchanged491 $this->assertEquals( 'unique-term', wp_unique_term_slug( 'unique-term', $c_term ) );492 493 // a non-hierarchicial dupe gets suffixed with "-#"494 $this->assertEquals( 'parent-2', wp_unique_term_slug( 'parent', $c_term ) );495 496 // a hierarchical dupe initially gets suffixed with its parent term497 $this->assertEquals( 'child-neighbor', wp_unique_term_slug( 'child', $d_term ) );498 499 // a hierarchical dupe whose parent already contains the {term}-{parent term}500 // term gets suffixed with parent term name and then '-#'501 $e = wp_insert_term( 'child-neighbor', $this->taxonomy, array( 'parent' => $c['term_id'] ) );502 $this->assertEquals( 'child-neighbor-2', wp_unique_term_slug( 'child', $d_term ) );503 504 $f = wp_insert_term( 'foo', $this->taxonomy );505 $this->assertInternalType( 'array', $f );506 $f_term = get_term( $f['term_id'], $this->taxonomy );507 $this->assertEquals( 'foo', $f_term->slug );508 $this->assertEquals( 'foo', wp_unique_term_slug( 'foo', $f_term ) );509 510 $g = wp_insert_term( 'foo', $this->taxonomy );511 $this->assertInstanceOf( 'WP_Error', $g );512 513 // clean up514 foreach ( array( $a, $b, $c, $d, $e, $f ) as $t )515 $this->assertTrue( wp_delete_term( $t['term_id'], $this->taxonomy ) );516 }517 518 474 /** 519 475 * @ticket 25852
Note: See TracChangeset
for help on using the changeset viewer.