Make WordPress Core

Changeset 1272 in tests


Ignore:
Timestamp:
04/25/2013 11:20:15 AM (11 years ago)
Author:
westi
Message:

Terms: Add a test case for #24189 which shows the invalid caching in action.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/term.php

    r1227 r1272  
    432432        $this->assertEquals( $expected_term_ids, $assigned_term_ids );
    433433    }
     434
     435    /**
     436     * @ticket 24189
     437     */
     438    function test_object_term_cache_when_term_changes() {
     439        $post_id = $this->factory->post->create();
     440        $tag_id = $this->factory->tag->create( array( 'description' => 'My Amazing Tag' ) );
     441
     442        $tt_1 = wp_set_object_terms( $post_id, $tag_id, 'post_tag' );
     443
     444        $terms = get_the_terms( $post_id, 'post_tag' );
     445        $this->assertEquals( $tag_id, $terms[0]->term_id );
     446        $this->assertEquals( 'My Amazing Tag', $terms[0]->description );
     447
     448        $_updated = wp_update_term( $tag_id, 'post_tag', array(
     449            'description' => 'This description is even more amazing!'
     450        ) );
     451
     452        $_new_term = get_term( $tag_id, 'post_tag' );
     453        $this->assertEquals( $tag_id, $_new_term->term_id );
     454        $this->assertEquals( 'This description is even more amazing!', $_new_term->description );
     455
     456        $terms = get_the_terms( $post_id, 'post_tag' );
     457        $this->assertEquals( $tag_id, $terms[0]->term_id );
     458        $this->assertEquals( 'This description is even more amazing!', $terms[0]->description );
     459    }
    434460}
Note: See TracChangeset for help on using the changeset viewer.