Make WordPress Core

Ticket #14485: 14485.3.diff

File 14485.3.diff, 3.3 KB (added by SergeyBiryukov, 11 years ago)
  • tests/phpunit/tests/term/cache.php

     
    1717                // Test with only one Parent => Child
    1818                $term_id1 = $this->factory->category->create();
    1919                $term_id1_child = $this->factory->category->create( array( 'parent' => $term_id1 ) );
     20
     21                $term_ids = array( $term_id1, $term_id1_child );
     22                clean_term_cache( $term_ids, 'category' );
     23
    2024                $hierarchy = _get_term_hierarchy( 'category' );
    2125
    2226                $this->assertEquals( array( $term_id1 => array( $term_id1_child ) ), $hierarchy );
     
    2428                // Add another Parent => Child
    2529                $term_id2 = $this->factory->category->create();
    2630                $term_id2_child = $this->factory->category->create( array( 'parent' => $term_id2 ) );
     31
     32                $term_ids = array( $term_id2, $term_id2_child );
     33                clean_term_cache( $term_ids, 'category' );
     34
    2735                $hierarchy = _get_term_hierarchy( 'category' );
    2836
    2937                $this->assertEquals( array( $term_id1 => array( $term_id1_child ), $term_id2 => array( $term_id2_child ) ), $hierarchy );
     
    7684                                break;
    7785                        }
    7886
     87                        clean_term_cache( $parent_id, $tax );
     88
    7989                        $terms = get_terms( $tax, array( 'hide_empty' => false ) );
    8090                        $this->assertEquals( $i, count( $terms ) );
    8191                        if ( $i > 1 ) {
  • tests/phpunit/tests/term/getTerms.php

     
    165165                $term_id2 = $this->factory->category->create();
    166166                $term_id22 = $this->factory->category->create( array( 'parent' => $term_id2 ) );
    167167
    168                 // There's something else broken in the cache cleaning routines that leads to this having to be done manually
    169                 delete_option( 'category_children' );
     168                $term_ids = array( $term_id1, $term_id11, $term_id2, $term_id22 );
     169                clean_term_cache( $term_ids, 'category' );
    170170
    171171                $terms = get_terms( 'category', array(
    172172                        'exclude' => $term_id_uncategorized,
     
    275275                $fruit = $this->factory->term->create( array( 'name' => 'Fruit', 'taxonomy' => $tax ) );
    276276                $cranberries = $this->factory->term->create( array( 'name' => 'Cranberries', 'parent' => $fruit, 'taxonomy' => $tax ) );
    277277
     278                $term_ids = array( $cheese, $cheddar, $brie, $crackers, $butter, $multigrain, $fruit, $cranberries );
     279                clean_term_cache( $term_ids, $tax );
     280
    278281                $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) );
    279282                $this->assertNotEmpty( $terms );
    280283                $this->assertEquals( wp_list_pluck( $terms, 'name' ), array( 'Cheese', 'Crackers' ) );
     
    295298                $term = get_term( $spread, $tax );
    296299                $this->assertEquals( 1, $term->count );
    297300
     301                $term_ids = array( $cheese, $cheddar, $spread );
     302                clean_term_cache( $term_ids, $tax );
     303
    298304                $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) );
    299305                $this->assertNotEmpty( $terms );
    300306                $this->assertEquals( array( 'Cheese' ), wp_list_pluck( $terms, 'name' ) );
     
    319325                $term = get_term( $t[7], $tax );
    320326                $this->assertEquals( 1, $term->count );
    321327
     328                clean_term_cache( $t, $tax );
     329
    322330                $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) );
    323331                $this->assertNotEmpty( $terms );
    324332                $this->assertEquals( array( 'term1' ), wp_list_pluck( $terms, 'name' ) );