Changeset 42343 for trunk/tests/phpunit/tests/term/cache.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/cache.php
r38776 r42343 16 16 function test_category_children_cache() { 17 17 // Test with only one Parent => Child 18 $term_id1 = self::factory()->category->create();18 $term_id1 = self::factory()->category->create(); 19 19 $term_id1_child = self::factory()->category->create( array( 'parent' => $term_id1 ) ); 20 $hierarchy = _get_term_hierarchy( 'category' );20 $hierarchy = _get_term_hierarchy( 'category' ); 21 21 22 22 $this->assertEquals( array( $term_id1 => array( $term_id1_child ) ), $hierarchy ); 23 23 24 24 // Add another Parent => Child 25 $term_id2 = self::factory()->category->create();25 $term_id2 = self::factory()->category->create(); 26 26 $term_id2_child = self::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 ); 27 $hierarchy = _get_term_hierarchy( 'category' ); 28 29 $this->assertEquals( 30 array( 31 $term_id1 => array( $term_id1_child ), 32 $term_id2 => array( $term_id2_child ), 33 ), $hierarchy 34 ); 30 35 } 31 36 … … 34 39 */ 35 40 function test_category_name_change() { 36 $term = self::factory()->category->create_and_get( array( 'name' => 'Foo' ) );41 $term = self::factory()->category->create_and_get( array( 'name' => 'Foo' ) ); 37 42 $post_id = self::factory()->post->create(); 38 43 wp_set_post_categories( $post_id, $term->term_id ); 39 44 40 $post = get_post( $post_id );45 $post = get_post( $post_id ); 41 46 $cats1 = get_the_category( $post->ID ); 42 47 $this->assertEquals( $term->name, reset( $cats1 )->name ); … … 55 60 $this->assertTrue( get_taxonomy( $tax )->hierarchical ); 56 61 57 $step = 1;62 $step = 1; 58 63 $parent_id = 0; 59 $children = 0;64 $children = 0; 60 65 61 66 foreach ( range( 1, 9 ) as $i ) { 62 67 switch ( $step ) { 63 case 1:64 $parent= wp_insert_term( 'Parent' . $i, $tax );65 $parent_id = $parent['term_id'];66 break;67 case 2:68 $parent= wp_insert_term( 'Child' . $i, $tax, array( 'parent' => $parent_id ) );69 $parent_id = $parent['term_id'];70 $children++;71 break;72 case 3:73 wp_insert_term( 'Grandchild' . $i, $tax, array( 'parent' => $parent_id ) );74 $parent_id = 0;75 $children++;76 break;68 case 1: 69 $parent = wp_insert_term( 'Parent' . $i, $tax ); 70 $parent_id = $parent['term_id']; 71 break; 72 case 2: 73 $parent = wp_insert_term( 'Child' . $i, $tax, array( 'parent' => $parent_id ) ); 74 $parent_id = $parent['term_id']; 75 $children++; 76 break; 77 case 3: 78 wp_insert_term( 'Grandchild' . $i, $tax, array( 'parent' => $parent_id ) ); 79 $parent_id = 0; 80 $children++; 81 break; 77 82 } 78 83 … … 99 104 100 105 register_taxonomy( 'wptests_tax', 'post' ); 101 $term = self::factory()->term->create( array( 102 'taxonomy' => 'wptests_tax', 103 ) ); 106 $term = self::factory()->term->create( 107 array( 108 'taxonomy' => 'wptests_tax', 109 ) 110 ); 104 111 105 112 $term_object = get_term( $term, 'wptests_tax' ); … … 125 132 126 133 register_taxonomy( 'wptests_tax', 'post' ); 127 $term = self::factory()->term->create( array( 128 'taxonomy' => 'wptests_tax', 129 ) ); 134 $term = self::factory()->term->create( 135 array( 136 'taxonomy' => 'wptests_tax', 137 ) 138 ); 130 139 131 140 wp_cache_delete( $term, 'terms' ); … … 152 161 153 162 register_taxonomy( 'wptests_tax', 'post' ); 154 $term = self::factory()->term->create( array( 155 'taxonomy' => 'wptests_tax', 156 ) ); 163 $term = self::factory()->term->create( 164 array( 165 'taxonomy' => 'wptests_tax', 166 ) 167 ); 157 168 158 169 wp_cache_delete( $term, 'terms' ); … … 183 194 register_taxonomy( 'wptests_tax', 'post' ); 184 195 185 $terms = self::factory()->term->create_many( 5, array( 186 'taxonomy' => 'wptests_tax', 187 ) ); 188 189 $term_objects = get_terms( 'wptests_tax', array( 190 'hide_empty' => false, 191 ) ); 196 $terms = self::factory()->term->create_many( 197 5, array( 198 'taxonomy' => 'wptests_tax', 199 ) 200 ); 201 202 $term_objects = get_terms( 203 'wptests_tax', array( 204 'hide_empty' => false, 205 ) 206 ); 192 207 193 208 $num_queries = $wpdb->num_queries; … … 227 242 global $wpdb; 228 243 229 $term_id = $this->factory->term->create( array( 'slug' => 'burrito', 'name' => 'Taco', 'taxonomy' => 'post_tag' ) ); 244 $term_id = $this->factory->term->create( 245 array( 246 'slug' => 'burrito', 247 'name' => 'Taco', 248 'taxonomy' => 'post_tag', 249 ) 250 ); 230 251 231 252 clean_term_cache( $term_id, 'post_tag' ); … … 252 273 global $wpdb; 253 274 254 $term_id = $this->factory->term->create( array( 'slug' => 'burrito', 'name' => 'Taco', 'taxonomy' => 'post_tag' ) ); 275 $term_id = $this->factory->term->create( 276 array( 277 'slug' => 'burrito', 278 'name' => 'Taco', 279 'taxonomy' => 'post_tag', 280 ) 281 ); 255 282 256 283 clean_term_cache( $term_id, 'post_tag' ); … … 284 311 global $wpdb; 285 312 286 $term_id = $this->factory->term->create( array( 'name' => 'Burrito', 'slug' => 'noburrito', 'taxonomy' => 'post_tag' ) ); 313 $term_id = $this->factory->term->create( 314 array( 315 'name' => 'Burrito', 316 'slug' => 'noburrito', 317 'taxonomy' => 'post_tag', 318 ) 319 ); 287 320 288 321 clean_term_cache( $term_id, 'post_tag' ); … … 307 340 global $wpdb; 308 341 309 $term_id = $this->factory->term->create( array( 'name' => 'Burrito', 'slug' => 'noburrito', 'taxonomy' => 'post_tag' ) ); 342 $term_id = $this->factory->term->create( 343 array( 344 'name' => 'Burrito', 345 'slug' => 'noburrito', 346 'taxonomy' => 'post_tag', 347 ) 348 ); 310 349 311 350 clean_term_cache( $term_id, 'post_tag' ); … … 336 375 global $wpdb; 337 376 338 $term_id = $this->factory->term->create( array( 'name' => 'Burrito', 'taxonomy' => 'post_tag' ) ); 339 340 clean_term_cache( $term_id, 'post_tag' ); 341 $num_queries = $wpdb->num_queries; 377 $term_id = $this->factory->term->create( 378 array( 379 'name' => 'Burrito', 380 'taxonomy' => 'post_tag', 381 ) 382 ); 383 384 clean_term_cache( $term_id, 'post_tag' ); 385 $num_queries = $wpdb->num_queries; 342 386 $last_changed = wp_cache_get( 'last_changed', 'terms' ); 343 387 … … 374 418 global $wpdb; 375 419 376 $term_id = $this->factory->term->create( array( 'name' => 'Burrito', 'taxonomy' => 'post_tag' ) ); 420 $term_id = $this->factory->term->create( 421 array( 422 'name' => 'Burrito', 423 'taxonomy' => 'post_tag', 424 ) 425 ); 377 426 add_term_meta( $term_id, 'foo', 'bar' ); 378 427 … … 410 459 * which will trigger an error in get_term(). 411 460 */ 412 $cached_ids = wp_cache_get( $p, 'wptests_tax_relationships' );461 $cached_ids = wp_cache_get( $p, 'wptests_tax_relationships' ); 413 462 $cached_ids[] = 0; 414 463 wp_cache_set( $p, $cached_ids, 'wptests_tax_relationships' );
Note: See TracChangeset
for help on using the changeset viewer.