Changeset 55745 for trunk/tests/phpunit/tests/term/getTerm.php
- Timestamp:
- 05/11/2023 10:05:51 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/getTerm.php
r52921 r55745 61 61 62 62 public function test_passing_term_object_should_skip_database_query_when_filter_property_is_empty() { 63 global $wpdb;64 65 63 $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) ); 66 64 clean_term_cache( $term->term_id, 'wptests_tax' ); 67 65 68 $num_queries = $wpdb->num_queries;66 $num_queries = get_num_queries(); 69 67 70 68 unset( $term->filter ); 71 69 $term_a = get_term( $term, 'wptests_tax' ); 72 70 73 $this->assertSame( $num_queries, $wpdb->num_queries);71 $this->assertSame( $num_queries, get_num_queries() ); 74 72 } 75 73 … … 83 81 84 82 public function test_cache_should_be_populated_by_successful_fetch() { 85 global $wpdb;86 87 83 $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); 88 84 clean_term_cache( $t, 'wptests_tax' ); … … 90 86 // Prime cache. 91 87 $term_a = get_term( $t, 'wptests_tax' ); 92 $num_queries = $wpdb->num_queries;88 $num_queries = get_num_queries(); 93 89 94 90 // Second call shouldn't require a database query. 95 91 $term_b = get_term( $t, 'wptests_tax' ); 96 $this->assertSame( $num_queries, $wpdb->num_queries);92 $this->assertSame( $num_queries, get_num_queries() ); 97 93 $this->assertEquals( $term_a, $term_b ); 98 94 } … … 197 193 */ 198 194 public function test_shared_term_in_cache_should_be_ignored_when_specifying_a_different_taxonomy() { 199 global $wpdb;200 201 195 $terms = $this->generate_shared_terms(); 202 196 203 197 // Prime cache for 'wptests_tax'. 204 198 get_term( $terms[0]['term_id'], 'wptests_tax' ); 205 $num_queries = $wpdb->num_queries;199 $num_queries = get_num_queries(); 206 200 207 201 // Database should be hit again. … … 209 203 $num_queries++; 210 204 211 $this->assertSame( $num_queries, $wpdb->num_queries);205 $this->assertSame( $num_queries, get_num_queries() ); 212 206 $this->assertInstanceOf( 'WP_Term', $found ); 213 207 $this->assertSame( 'wptests_tax_2', $found->taxonomy );
Note: See TracChangeset
for help on using the changeset viewer.