Changeset 47338 for branches/3.8/tests/phpunit/tests/term.php
- Timestamp:
- 02/21/2020 01:05:39 PM (5 years ago)
- Location:
- branches/3.8
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.8
- Property svn:mergeinfo changed
-
branches/3.8/tests/phpunit/tests/term.php
r26511 r47338 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 */ … … 495 449 496 450 $this->assertEquals( $expected_term_ids, $assigned_term_ids ); 497 }498 499 /**500 * @ticket 24189501 */502 function test_object_term_cache_when_term_changes() {503 $post_id = $this->factory->post->create();504 $tag_id = $this->factory->tag->create( array( 'description' => 'My Amazing Tag' ) );505 506 $tt_1 = wp_set_object_terms( $post_id, $tag_id, 'post_tag' );507 508 $terms = get_the_terms( $post_id, 'post_tag' );509 $this->assertEquals( $tag_id, $terms[0]->term_id );510 $this->assertEquals( 'My Amazing Tag', $terms[0]->description );511 512 $_updated = wp_update_term( $tag_id, 'post_tag', array(513 'description' => 'This description is even more amazing!'514 ) );515 516 $_new_term = get_term( $tag_id, 'post_tag' );517 $this->assertEquals( $tag_id, $_new_term->term_id );518 $this->assertEquals( 'This description is even more amazing!', $_new_term->description );519 520 $terms = get_the_terms( $post_id, 'post_tag' );521 $this->assertEquals( $tag_id, $terms[0]->term_id );522 $this->assertEquals( 'This description is even more amazing!', $terms[0]->description );523 451 } 524 452
Note: See TracChangeset
for help on using the changeset viewer.