Changeset 42343 for trunk/tests/phpunit/tests/term/meta.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/meta.php
r41662 r42343 54 54 add_term_meta( $t, 'foo1', 'baz' ); 55 55 56 $found = get_term_meta( $t );56 $found = get_term_meta( $t ); 57 57 $expected = array( 58 'foo' => array( 'bar' ),58 'foo' => array( 'bar' ), 59 59 'foo1' => array( 'baz' ), 60 60 ); … … 69 69 add_term_meta( $t, 'foo1', 'baz' ); 70 70 71 $found = get_term_meta( $t, 'foo' );71 $found = get_term_meta( $t, 'foo' ); 72 72 $expected = array( 'bar', 'baz' ); 73 73 … … 155 155 */ 156 156 public function test_lazy_load_term_meta_should_fall_back_on_update_post_term_cache() { 157 $q = new WP_Query( array( 158 'update_post_term_cache' => true, 159 ) ); 157 $q = new WP_Query( 158 array( 159 'update_post_term_cache' => true, 160 ) 161 ); 160 162 161 163 $this->assertTrue( $q->get( 'lazy_load_term_meta' ) ); 162 164 163 $q = new WP_Query( array( 164 'update_post_term_cache' => false, 165 ) ); 165 $q = new WP_Query( 166 array( 167 'update_post_term_cache' => false, 168 ) 169 ); 166 170 167 171 $this->assertFalse( $q->get( 'lazy_load_term_meta' ) ); … … 183 187 } 184 188 185 $q = new WP_Query( array( 186 'cache_results' => true, 187 'update_post_term_cache' => true, 188 'lazy_load_term_meta' => false, 189 ) ); 189 $q = new WP_Query( 190 array( 191 'cache_results' => true, 192 'update_post_term_cache' => true, 193 'lazy_load_term_meta' => false, 194 ) 195 ); 190 196 191 197 if ( $q->have_posts() ) { … … 212 218 213 219 // Prime cache. 214 $found = get_terms( 'wptests_tax', array( 215 'hide_empty' => false, 216 'fields' => 'ids', 217 'meta_query' => array( 218 array( 219 'key' => 'foo', 220 'value' => 'bar', 221 ), 222 ), 223 ) ); 220 $found = get_terms( 221 'wptests_tax', array( 222 'hide_empty' => false, 223 'fields' => 'ids', 224 'meta_query' => array( 225 array( 226 'key' => 'foo', 227 'value' => 'bar', 228 ), 229 ), 230 ) 231 ); 224 232 225 233 $this->assertEqualSets( array( $terms[0] ), $found ); … … 227 235 add_term_meta( $terms[1], 'foo', 'bar' ); 228 236 229 $found = get_terms( 'wptests_tax', array( 230 'hide_empty' => false, 231 'fields' => 'ids', 232 'meta_query' => array( 233 array( 234 'key' => 'foo', 235 'value' => 'bar', 236 ), 237 ), 238 ) ); 237 $found = get_terms( 238 'wptests_tax', array( 239 'hide_empty' => false, 240 'fields' => 'ids', 241 'meta_query' => array( 242 array( 243 'key' => 'foo', 244 'value' => 'bar', 245 ), 246 ), 247 ) 248 ); 239 249 240 250 $this->assertEqualSets( array( $terms[0], $terms[1] ), $found ); … … 248 258 249 259 // Prime cache. 250 $found = get_terms( 'wptests_tax', array( 251 'hide_empty' => false, 252 'fields' => 'ids', 253 'meta_query' => array( 254 array( 255 'key' => 'foo', 256 'value' => 'bar', 257 ), 258 ), 259 ) ); 260 $found = get_terms( 261 'wptests_tax', array( 262 'hide_empty' => false, 263 'fields' => 'ids', 264 'meta_query' => array( 265 array( 266 'key' => 'foo', 267 'value' => 'bar', 268 ), 269 ), 270 ) 271 ); 260 272 261 273 $this->assertEqualSets( array( $terms[0] ), $found ); … … 263 275 update_term_meta( $terms[1], 'foo', 'bar' ); 264 276 265 $found = get_terms( 'wptests_tax', array( 266 'hide_empty' => false, 267 'fields' => 'ids', 268 'meta_query' => array( 269 array( 270 'key' => 'foo', 271 'value' => 'bar', 272 ), 273 ), 274 ) ); 277 $found = get_terms( 278 'wptests_tax', array( 279 'hide_empty' => false, 280 'fields' => 'ids', 281 'meta_query' => array( 282 array( 283 'key' => 'foo', 284 'value' => 'bar', 285 ), 286 ), 287 ) 288 ); 275 289 276 290 $this->assertEqualSets( array( $terms[0], $terms[1] ), $found ); … … 284 298 285 299 // Prime cache. 286 $found = get_terms( 'wptests_tax', array( 287 'hide_empty' => false, 288 'fields' => 'ids', 289 'meta_query' => array( 290 array( 291 'key' => 'foo', 292 'value' => 'bar', 293 ), 294 ), 295 ) ); 300 $found = get_terms( 301 'wptests_tax', array( 302 'hide_empty' => false, 303 'fields' => 'ids', 304 'meta_query' => array( 305 array( 306 'key' => 'foo', 307 'value' => 'bar', 308 ), 309 ), 310 ) 311 ); 296 312 297 313 $this->assertEqualSets( array( $terms[0], $terms[1] ), $found ); … … 299 315 delete_term_meta( $terms[1], 'foo', 'bar' ); 300 316 301 $found = get_terms( 'wptests_tax', array( 302 'hide_empty' => false, 303 'fields' => 'ids', 304 'meta_query' => array( 305 array( 306 'key' => 'foo', 307 'value' => 'bar', 308 ), 309 ), 310 ) ); 317 $found = get_terms( 318 'wptests_tax', array( 319 'hide_empty' => false, 320 'fields' => 'ids', 321 'meta_query' => array( 322 array( 323 'key' => 'foo', 324 'value' => 'bar', 325 ), 326 ), 327 ) 328 ); 311 329 312 330 $this->assertEqualSets( array( $terms[0] ), $found ); … … 330 348 331 349 // Manually modify because shared terms shouldn't naturally occur. 332 $wpdb->update( $wpdb->term_taxonomy, 350 $wpdb->update( 351 $wpdb->term_taxonomy, 333 352 array( 'term_id' => $t1['term_id'] ), 334 353 array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ), … … 337 356 ); 338 357 339 $wpdb->update( $wpdb->term_taxonomy, 358 $wpdb->update( 359 $wpdb->term_taxonomy, 340 360 array( 'term_id' => $t1['term_id'] ), 341 361 array( 'term_taxonomy_id' => $t3['term_taxonomy_id'] ), … … 368 388 369 389 // Manually modify because shared terms shouldn't naturally occur. 370 $wpdb->update( $wpdb->term_taxonomy, 390 $wpdb->update( 391 $wpdb->term_taxonomy, 371 392 array( 'term_id' => $t1['term_id'] ), 372 393 array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ), … … 375 396 ); 376 397 377 $wpdb->update( $wpdb->term_taxonomy, 398 $wpdb->update( 399 $wpdb->term_taxonomy, 378 400 array( 'term_id' => $t1['term_id'] ), 379 401 array( 'term_taxonomy_id' => $t3['term_taxonomy_id'] ), … … 412 434 413 435 $term_meta_id = add_term_meta( $t, 'foo', 'bar' ); 414 $meta = has_term_meta( $t );436 $meta = has_term_meta( $t ); 415 437 416 438 $this->assertSame( 1, count( $meta ) ); 417 439 418 440 $expected = array( 419 'meta_key' => 'foo',441 'meta_key' => 'foo', 420 442 'meta_value' => 'bar', 421 'meta_id' => $term_meta_id,422 'term_id' => $t,443 'meta_id' => $term_meta_id, 444 'term_id' => $t, 423 445 ); 424 446
Note: See TracChangeset
for help on using the changeset viewer.