Changeset 44983 for trunk/tests/phpunit/tests/multisite/siteQuery.php
- Timestamp:
- 03/22/2019 05:25:38 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/multisite/siteQuery.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/siteQuery.php
r43010 r44983 910 910 $this->assertEqualSets( $expected, $found ); 911 911 } 912 } 913 914 915 /** 916 * @ticket 45749 917 */ 918 public function test_sites_pre_query_filter_should_bypass_database_query() { 919 global $wpdb; 920 921 add_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 ); 922 923 $num_queries = $wpdb->num_queries; 924 925 $q = new WP_Site_Query(); 926 $results = $q->query( 927 array( 928 'fields' => 'ids', 929 ) 930 ); 931 932 remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 ); 933 934 // Make sure no queries were executed. 935 $this->assertSame( $num_queries, $wpdb->num_queries ); 936 937 // We manually inserted a non-existing site and overrode the results with it. 938 $this->assertSame( array( 555 ), $q->sites ); 939 940 // Make sure manually setting total_users doesn't get overwritten. 941 $this->assertEquals( 1, $q->found_sites ); 942 } 943 944 public static function filter_sites_pre_query( $sites, $query ) { 945 $query->found_sites = 1; 946 947 return array( 555 ); 912 948 } 913 949
Note: See TracChangeset
for help on using the changeset viewer.