Changeset 34812 for trunk/tests/phpunit/tests/term/isObjectInTerm.php
- Timestamp:
- 10/03/2015 09:18:55 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/isObjectInTerm.php
r30205 r34812 101 101 $this->assertTrue( is_object_in_term( $post_ID, 'wptests_tax', $int_tax_name ) ); 102 102 } 103 104 /** 105 * @ticket 32044 106 */ 107 public function test_should_populate_and_hit_relationships_cache() { 108 global $wpdb; 109 110 register_taxonomy( 'wptests_tax', 'post' ); 111 $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); 112 113 $o = 12345; 114 wp_set_object_terms( $o, $terms[0], 'wptests_tax' ); 115 116 $num_queries = $wpdb->num_queries; 117 $this->assertTrue( is_object_in_term( $o, 'wptests_tax', $terms[0] ) ); 118 $num_queries++; 119 $this->assertSame( $num_queries, $wpdb->num_queries ); 120 121 $this->assertFalse( is_object_in_term( $o, 'wptests_tax', $terms[1] ) ); 122 $this->assertSame( $num_queries, $wpdb->num_queries ); 123 } 124 125 /** 126 * @ticket 32044 127 */ 128 public function test_should_not_be_fooled_by_a_stale_relationship_cache() { 129 global $wpdb; 130 131 register_taxonomy( 'wptests_tax', 'post' ); 132 $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); 133 134 $o = 12345; 135 wp_set_object_terms( $o, $terms[0], 'wptests_tax' ); 136 137 $num_queries = $wpdb->num_queries; 138 $this->assertTrue( is_object_in_term( $o, 'wptests_tax', $terms[0] ) ); 139 $num_queries++; 140 $this->assertSame( $num_queries, $wpdb->num_queries ); 141 142 wp_set_object_terms( $o, $terms[1], 'wptests_tax' ); 143 144 $num_queries = $wpdb->num_queries; 145 $this->assertTrue( is_object_in_term( $o, 'wptests_tax', $terms[1] ) ); 146 $num_queries++; 147 $this->assertSame( $num_queries, $wpdb->num_queries ); 148 } 103 149 }
Note: See TracChangeset
for help on using the changeset viewer.