Changeset 37567 for trunk/tests/phpunit/tests/term/wpGetObjectTerms.php
- Timestamp:
- 05/25/2016 06:44:00 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/wpGetObjectTerms.php
r35242 r37567 474 474 475 475 /** 476 * @ticket 36932 477 */ 478 public function test_termmeta_cache_should_be_primed_when_fields_is_all_with_object_id() { 479 global $wpdb; 480 481 register_taxonomy( 'wptests_tax', 'post' ); 482 $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); 483 add_term_meta( $terms[0], 'foo', 'bar' ); 484 add_term_meta( $terms[1], 'foo', 'bar' ); 485 add_term_meta( $terms[2], 'foo', 'bar' ); 486 487 $p = self::factory()->post->create(); 488 wp_set_object_terms( $p, $terms, 'wptests_tax' ); 489 490 $found = wp_get_object_terms( $p, 'wptests_tax', array( 491 'update_term_meta_cache' => true, 492 'fields' => 'all_with_object_id', 493 ) ); 494 495 $num_queries = $wpdb->num_queries; 496 497 foreach ( $terms as $t ) { 498 $this->assertSame( 'bar', get_term_meta( $t, 'foo', true ) ); 499 } 500 501 $this->assertSame( $num_queries, $wpdb->num_queries ); 502 } 503 504 /** 505 * @ticket 36932 506 */ 507 public function test_termmeta_cache_should_be_primed_when_fields_is_ids() { 508 global $wpdb; 509 510 register_taxonomy( 'wptests_tax', 'post' ); 511 $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); 512 add_term_meta( $terms[0], 'foo', 'bar' ); 513 add_term_meta( $terms[1], 'foo', 'bar' ); 514 add_term_meta( $terms[2], 'foo', 'bar' ); 515 516 $p = self::factory()->post->create(); 517 wp_set_object_terms( $p, $terms, 'wptests_tax' ); 518 519 $found = wp_get_object_terms( $p, 'wptests_tax', array( 520 'update_term_meta_cache' => true, 521 'fields' => 'ids', 522 ) ); 523 524 $num_queries = $wpdb->num_queries; 525 526 foreach ( $terms as $t ) { 527 $this->assertSame( 'bar', get_term_meta( $t, 'foo', true ) ); 528 } 529 530 $this->assertSame( $num_queries, $wpdb->num_queries ); 531 } 532 533 /** 476 534 * @ticket 10142 477 535 */
Note: See TracChangeset
for help on using the changeset viewer.