Changeset 45584 for trunk/tests/phpunit/tests/term/query.php
- Timestamp:
- 07/01/2019 08:47:21 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/term/query.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/query.php
r43571 r45584 738 738 return $term; 739 739 } 740 741 /** 742 * @ticket 41246 743 */ 744 public function test_terms_pre_query_filter_should_bypass_database_query() { 745 global $wpdb; 746 747 add_filter( 'terms_pre_query', array( __CLASS__, 'filter_terms_pre_query' ), 10, 2 ); 748 749 $num_queries = $wpdb->num_queries; 750 751 $q = new WP_Term_Query(); 752 $results = $q->query( 753 array( 754 'fields' => 'ids', 755 ) 756 ); 757 758 remove_filter( 'terms_pre_query', array( __CLASS__, 'filter_terms_pre_query' ), 10, 2 ); 759 760 // Make sure no queries were executed. 761 $this->assertSame( $num_queries, $wpdb->num_queries ); 762 763 // We manually inserted a non-existing term and overrode the results with it. 764 $this->assertSame( array( 555 ), $q->terms ); 765 } 766 767 public static function filter_terms_pre_query( $terms, $query ) { 768 return array( 555 ); 769 } 740 770 }
Note: See TracChangeset
for help on using the changeset viewer.