| | 1 | <?php |
| | 2 | |
| | 3 | /** |
| | 4 | * @group taxonomy |
| | 5 | */ |
| | 6 | class Tests_Term_Cache extends WP_UnitTestCase { |
| | 7 | function setUp() { |
| | 8 | parent::setUp(); |
| | 9 | |
| | 10 | wp_cache_delete( 'last_changed', 'terms' ); |
| | 11 | } |
| | 12 | |
| | 13 | /** |
| | 14 | * @ticket 25711 |
| | 15 | */ |
| | 16 | function test_category_children_cache() { |
| | 17 | // Test with only one Parent => Child |
| | 18 | $term_id1 = $this->factory->category->create(); |
| | 19 | $term_id1_child = $this->factory->category->create( array( 'parent' => $term_id1 ) ); |
| | 20 | $hierarchy = _get_term_hierarchy( 'category' ); |
| | 21 | |
| | 22 | $this->assertEquals( array( $term_id1 => array( $term_id1_child ) ), $hierarchy ); |
| | 23 | |
| | 24 | // Add another Parent => Child |
| | 25 | $term_id2 = $this->factory->category->create(); |
| | 26 | $term_id2_child = $this->factory->category->create( array( 'parent' => $term_id2 ) ); |
| | 27 | $hierarchy = _get_term_hierarchy( 'category' ); |
| | 28 | |
| | 29 | $this->assertEquals( array( $term_id1 => array( $term_id1_child ), $term_id2 => array( $term_id2_child ) ), $hierarchy ); |
| | 30 | |
| | 31 | } |
| | 32 | } |
| | 33 | No newline at end of file |