Changeset 27104 for trunk/tests/phpunit/tests/term.php
- Timestamp:
- 02/06/2014 05:19:05 AM (12 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/term.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term.php
r27102 r27104 568 568 $this->assertEquals( 0, $count ); 569 569 } 570 571 /**572 * @ticket 22526573 */574 function test_get_taxonomy_last_changed() {575 $last_changed = get_taxonomy_last_changed( 'category' );576 $last_changed_cache = wp_cache_get( 'last_changed', 'category' );577 $this->assertEquals( $last_changed, $last_changed_cache );578 wp_cache_delete( 'last_changed', 'category' );579 $this->assertEquals( $last_changed, $last_changed_cache );580 $last_changed = get_taxonomy_last_changed( 'category' );581 $this->assertNotEquals( $last_changed, $last_changed_cache );582 583 $last_changed2 = get_taxonomy_last_changed( 'category' );584 $this->factory->category->create();585 $last_changed3 = get_taxonomy_last_changed( 'category' );586 $this->assertNotEquals( $last_changed2, $last_changed3 );587 }588 589 /**590 * @ticket 22526591 */592 function test_set_taxonomy_last_changed() {593 $last_changed1 = set_taxonomy_last_changed( 'category' );594 $last_changed2 = set_taxonomy_last_changed( 'category' );595 $this->assertNotEquals( $last_changed1, $last_changed2 );596 597 $last_changed3 = set_taxonomy_last_changed( 'category' );598 $last_changed4 = get_taxonomy_last_changed( 'category' );599 $this->assertEquals( $last_changed3, $last_changed4 );600 }601 602 /**603 * @ticket 22526604 */605 function test_post_taxonomy_is_fresh() {606 $post_id = $this->factory->post->create();607 $term_id = $this->factory->category->create( array( 'name' => 'Foo' ) );608 wp_set_post_categories( $post_id, $term_id );609 610 $this->assertFalse( post_taxonomy_is_fresh( $post_id, 'category' ) );611 $this->assertTrue( post_taxonomy_is_fresh( $post_id, 'category' ) );612 $this->assertTrue( post_taxonomy_is_fresh( $post_id, 'category' ) );613 614 wp_update_term( $term_id, 'category', array( 'name' => 'Bar' ) );615 616 $this->assertFalse( post_taxonomy_is_fresh( $post_id, 'category' ) );617 get_the_category( $post_id );618 $this->assertTrue( post_taxonomy_is_fresh( $post_id, 'category' ) );619 }620 621 /**622 * @ticket 22526623 */624 function test_category_name_change() {625 $term = $this->factory->category->create_and_get( array( 'name' => 'Foo' ) );626 $post_id = $this->factory->post->create();627 wp_set_post_categories( $post_id, $term->term_id );628 629 $post = get_post( $post_id );630 $cats1 = get_the_category( $post->ID );631 $this->assertEquals( $term->name, reset( $cats1 )->name );632 633 wp_update_term( $term->term_id, 'category', array( 'name' => 'Bar' ) );634 $cats2 = get_the_category( $post->ID );635 $this->assertNotEquals( $term->name, reset( $cats2 )->name );636 }637 638 function test_hierachy_invalidation() {639 $tax = 'burrito';640 register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );641 $this->assertTrue( get_taxonomy( $tax )->hierarchical );642 643 $step = 1;644 $parent_id = 0;645 $children = 0;646 647 foreach ( range( 1, 99 ) as $i ) {648 switch ( $step ) {649 case 1:650 $parent = wp_insert_term( 'Parent' . $i, $tax );651 $parent_id = $parent['term_id'];652 break;653 case 2:654 $parent = wp_insert_term( 'Child' . $i, $tax, array( 'parent' => $parent_id ) );655 $parent_id = $parent['term_id'];656 $children++;657 break;658 case 3:659 wp_insert_term( 'Grandchild' . $i, $tax, array( 'parent' => $parent_id ) );660 $parent_id = 0;661 $children++;662 break;663 }664 665 $terms = get_terms( $tax, array( 'hide_empty' => false ) );666 $this->assertEquals( $i, count( $terms ) );667 if ( 1 < $i ) {668 $hierarchy = _get_term_hierarchy( $tax );669 $this->assertNotEmpty( $hierarchy );670 $this->assertEquals( $children, count( $hierarchy, COUNT_RECURSIVE ) - count( $hierarchy ) );671 }672 673 if ( $i % 3 === 0 ) {674 $step = 1;675 } else {676 $step++;677 }678 }679 680 _unregister_taxonomy( $tax );681 }682 570 }
Note: See TracChangeset
for help on using the changeset viewer.