Changeset 47329 for branches/3.9/tests/phpunit/tests/term.php
- Timestamp:
- 02/20/2020 05:04:42 PM (5 years ago)
- Location:
- branches/3.9
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.9
-
branches/3.9/tests/phpunit/tests/term.php
r27104 r47329 413 413 414 414 /** 415 * @ticket 5809416 */417 function test_update_shared_term() {418 $random_tax = __FUNCTION__;419 420 register_taxonomy( $random_tax, 'post' );421 422 $post_id = $this->factory->post->create();423 424 $old_name = 'Initial';425 426 $t1 = wp_insert_term( $old_name, 'category' );427 $t2 = wp_insert_term( $old_name, 'post_tag' );428 429 $this->assertEquals( $t1['term_id'], $t2['term_id'] );430 431 wp_set_post_categories( $post_id, array( $t1['term_id'] ) );432 wp_set_post_tags( $post_id, array( (int) $t2['term_id'] ) );433 434 $new_name = 'Updated';435 436 // create the term in a third taxonomy, just to keep things interesting437 $t3 = wp_insert_term( $old_name, $random_tax );438 wp_set_post_terms( $post_id, array( (int) $t3['term_id'] ), $random_tax );439 $this->assertPostHasTerms( $post_id, array( $t3['term_id'] ), $random_tax );440 441 $t2_updated = wp_update_term( $t2['term_id'], 'post_tag', array(442 'name' => $new_name443 ) );444 445 $this->assertNotEquals( $t2_updated['term_id'], $t3['term_id'] );446 447 // make sure the terms have split448 $this->assertEquals( $old_name, get_term_field( 'name', $t1['term_id'], 'category' ) );449 $this->assertEquals( $new_name, get_term_field( 'name', $t2_updated['term_id'], 'post_tag' ) );450 451 // and that they are still assigned to the correct post452 $this->assertPostHasTerms( $post_id, array( $t1['term_id'] ), 'category' );453 $this->assertPostHasTerms( $post_id, array( $t2_updated['term_id'] ), 'post_tag' );454 $this->assertPostHasTerms( $post_id, array( $t3['term_id'] ), $random_tax );455 456 // clean up457 unset( $GLOBALS['wp_taxonomies'][ $random_tax ] );458 }459 460 /**461 415 * @ticket 17646 462 416 */
Note: See TracChangeset
for help on using the changeset viewer.