Changeset 34529 for trunk/tests/phpunit/tests/term/getTerms.php
- Timestamp:
- 09/25/2015 03:58:59 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/term/getTerms.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/getTerms.php
r33903 r34529 23 23 24 24 // last_changed and num_queries should bump 25 $terms = get_terms( 'post_tag' );25 $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) ); 26 26 $this->assertEquals( 3, count( $terms ) ); 27 27 $time1 = wp_cache_get( 'last_changed', 'terms' ); … … 32 32 33 33 // Again. last_changed and num_queries should remain the same. 34 $terms = get_terms( 'post_tag' );34 $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) ); 35 35 $this->assertEquals( 3, count( $terms ) ); 36 36 $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'terms' ) ); … … 1503 1503 } 1504 1504 1505 /** 1506 * @ticket 10142 1507 */ 1508 public function test_termmeta_cache_should_be_primed_by_default() { 1509 global $wpdb; 1510 1511 register_taxonomy( 'wptests_tax', 'post' ); 1512 $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); 1513 add_term_meta( $terms[0], 'foo', 'bar' ); 1514 add_term_meta( $terms[1], 'foo', 'bar' ); 1515 add_term_meta( $terms[2], 'foo', 'bar' ); 1516 1517 $found = get_terms( 'wptests_tax', array( 1518 'hide_empty' => false, 1519 'include' => $terms, 1520 ) ); 1521 1522 $num_queries = $wpdb->num_queries; 1523 1524 foreach ( $terms as $t ) { 1525 $this->assertSame( 'bar', get_term_meta( $t, 'foo', true ) ); 1526 } 1527 1528 $this->assertSame( $num_queries, $wpdb->num_queries ); 1529 } 1530 1531 /** 1532 * @ticket 10142 1533 */ 1534 public function test_termmeta_cache_should_not_be_primed_when_update_term_meta_cache_is_false() { 1535 global $wpdb; 1536 1537 register_taxonomy( 'wptests_tax', 'post' ); 1538 $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); 1539 add_term_meta( $terms[0], 'foo', 'bar' ); 1540 add_term_meta( $terms[1], 'foo', 'bar' ); 1541 add_term_meta( $terms[2], 'foo', 'bar' ); 1542 1543 $found = get_terms( 'wptests_tax', array( 1544 'hide_empty' => false, 1545 'include' => $terms, 1546 'update_term_meta_cache' => false, 1547 ) ); 1548 1549 $num_queries = $wpdb->num_queries; 1550 1551 foreach ( $terms as $t ) { 1552 $this->assertSame( 'bar', get_term_meta( $t, 'foo', true ) ); 1553 } 1554 1555 $this->assertSame( $num_queries + 3, $wpdb->num_queries ); 1556 } 1557 1558 /** 1559 * @ticket 10142 1560 */ 1561 public function test_meta_query() { 1562 register_taxonomy( 'wptests_tax', 'post' ); 1563 $terms = $this->factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) ); 1564 add_term_meta( $terms[0], 'foo', 'bar' ); 1565 add_term_meta( $terms[1], 'foo', 'bar' ); 1566 add_term_meta( $terms[2], 'foo', 'baz' ); 1567 add_term_meta( $terms[3], 'foob', 'ar' ); 1568 1569 $found = get_terms( 'wptests_tax', array( 1570 'hide_empty' => false, 1571 'meta_query' => array( 1572 array( 1573 'key' => 'foo', 1574 'value' => 'bar', 1575 ), 1576 ), 1577 'fields' => 'ids', 1578 ) ); 1579 1580 $this->assertEqualSets( array( $terms[0], $terms[1] ), $found ); 1581 } 1582 1505 1583 protected function create_hierarchical_terms_and_posts() { 1506 1584 $terms = array();
Note: See TracChangeset
for help on using the changeset viewer.