Changeset 1048 in tests for trunk/tests/term.php
- Timestamp:
- 09/26/2012 10:57:32 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/term.php
r1042 r1048 325 325 */ 326 326 function test_update_shared_term() { 327 $post_id = $this->factory->post->create(); 328 329 $term_1 = 'Initial'; 330 331 $t1 = wp_insert_term( $term_1, 'category' ); 332 $t2 = wp_insert_term( $term_1, 'post_tag' ); 327 $random_tax = __FUNCTION__; 328 329 register_taxonomy( $random_tax, 'post' ); 330 331 $post_id = $this->factory->post->create(); 332 333 $old_name = 'Initial'; 334 335 $t1 = wp_insert_term( $old_name, 'category' ); 336 $t2 = wp_insert_term( $old_name, 'post_tag' ); 333 337 334 338 $this->assertEquals( $t1['term_id'], $t2['term_id'] ); … … 337 341 wp_set_post_tags( $post_id, array( (int) $t2['term_id'] ) ); 338 342 339 $term_2 = 'Updated'; 343 $new_name = 'Updated'; 344 345 // create the term in a third taxonomy, just to keep things interesting 346 $t3 = wp_insert_term( $old_name, $random_tax ); 347 wp_set_post_terms( $post_id, array( (int) $t3['term_id'] ), $random_tax ); 348 $this->assertPostHasTerms( $post_id, array( $t3['term_id'] ), $random_tax ); 349 340 350 $t2_updated = wp_update_term( $t2['term_id'], 'post_tag', array( 341 'name' => $ term_2351 'name' => $new_name 342 352 ) ); 343 353 354 $this->assertNotEquals( $t2_updated['term_id'], $t3['term_id'] ); 355 344 356 // make sure the terms have split 345 $this->assertEquals( $ term_1, get_term_field( 'name', $t1['term_id'], 'category' ) );346 $this->assertEquals( $ term_2, get_term_field( 'name', $t2_updated['term_id'], 'post_tag' ) );347 348 // and that they are assigned to the correct post357 $this->assertEquals( $old_name, get_term_field( 'name', $t1['term_id'], 'category' ) ); 358 $this->assertEquals( $new_name, get_term_field( 'name', $t2_updated['term_id'], 'post_tag' ) ); 359 360 // and that they are still assigned to the correct post 349 361 $this->assertPostHasTerms( $post_id, array( $t1['term_id'] ), 'category' ); 350 362 $this->assertPostHasTerms( $post_id, array( $t2_updated['term_id'] ), 'post_tag' ); 363 $this->assertPostHasTerms( $post_id, array( $t3['term_id'] ), $random_tax ); 364 365 // clean up 366 unset( $GLOBALS['wp_taxonomies'][ $random_tax ] ); 351 367 } 352 368
Note: See TracChangeset
for help on using the changeset viewer.