Changeset 40446
- Timestamp:
- 04/15/2017 07:38:18 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.0/tests/phpunit/tests/term.php
r29196 r40446 572 572 573 573 /** 574 * @ticket 5809575 */576 function test_update_shared_term() {577 $random_tax = __FUNCTION__;578 579 register_taxonomy( $random_tax, 'post' );580 581 $post_id = $this->factory->post->create();582 583 $old_name = 'Initial';584 585 $t1 = wp_insert_term( $old_name, 'category' );586 $t2 = wp_insert_term( $old_name, 'post_tag' );587 588 $this->assertEquals( $t1['term_id'], $t2['term_id'] );589 590 wp_set_post_categories( $post_id, array( $t1['term_id'] ) );591 wp_set_post_tags( $post_id, array( (int) $t2['term_id'] ) );592 593 $new_name = 'Updated';594 595 // create the term in a third taxonomy, just to keep things interesting596 $t3 = wp_insert_term( $old_name, $random_tax );597 wp_set_post_terms( $post_id, array( (int) $t3['term_id'] ), $random_tax );598 $this->assertPostHasTerms( $post_id, array( $t3['term_id'] ), $random_tax );599 600 $t2_updated = wp_update_term( $t2['term_id'], 'post_tag', array(601 'name' => $new_name602 ) );603 604 $this->assertNotEquals( $t2_updated['term_id'], $t3['term_id'] );605 606 // make sure the terms have split607 $this->assertEquals( $old_name, get_term_field( 'name', $t1['term_id'], 'category' ) );608 $this->assertEquals( $new_name, get_term_field( 'name', $t2_updated['term_id'], 'post_tag' ) );609 610 // and that they are still assigned to the correct post611 $this->assertPostHasTerms( $post_id, array( $t1['term_id'] ), 'category' );612 $this->assertPostHasTerms( $post_id, array( $t2_updated['term_id'] ), 'post_tag' );613 $this->assertPostHasTerms( $post_id, array( $t3['term_id'] ), $random_tax );614 615 // clean up616 unset( $GLOBALS['wp_taxonomies'][ $random_tax ] );617 }618 619 /**620 574 * @ticket 25852 621 575 */
Note: See TracChangeset
for help on using the changeset viewer.