Changeset 52836 for trunk/tests/phpunit/tests/term/getTermBy.php
- Timestamp:
- 03/10/2022 10:56:09 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/getTermBy.php
r52010 r52836 5 5 */ 6 6 class Tests_Term_GetTermBy extends WP_UnitTestCase { 7 8 protected $query = ''; 7 9 8 10 public function test_get_term_by_slug() { … … 124 126 $num_queries = $wpdb->num_queries; 125 127 $found = get_term_by( 'slug', 'foo', 'wptests_tax' ); 126 $num_queries ++;128 $num_queries = $num_queries + 2; 127 129 128 130 $this->assertInstanceOf( 'WP_Term', $found ); … … 210 212 */ 211 213 public function test_query_should_contain_limit_clause() { 212 global $wpdb;213 214 214 $term_id = $this->factory->term->create( 215 215 array( … … 218 218 ) 219 219 ); 220 $found = get_term_by( 'name', 'burrito', 'post_tag' ); 221 $this->assertSame( $term_id, $found->term_id ); 222 $this->assertStringContainsString( 'LIMIT 1', $wpdb->last_query ); 220 add_filter( 'terms_pre_query', array( $this, 'get_query_from_filter' ), 10, 2 ); 221 $found = get_term_by( 'name', 'burrito', 'post_tag' ); 222 $this->assertSame( $term_id, $found->term_id ); 223 $this->assertStringContainsString( 'LIMIT 1', $this->query ); 223 224 } 224 225 … … 283 284 $this->assertFalse( $found_by_name ); 284 285 } 286 287 public function get_query_from_filter( $terms, $wp_term_query ) { 288 $this->query = $wp_term_query->request; 289 290 return $terms; 291 } 285 292 }
Note: See TracChangeset
for help on using the changeset viewer.