Make WordPress Core

Changeset 48988


Ignore:
Timestamp:
09/17/2020 11:28:05 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Tests: Move the data_wp_site_query_meta_query() data provider next to the test it's used in.

See #50767.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/siteQuery.php

    r48987 r48988  
    908908                $this->assertSameSets( $expected, $found );
    909909            }
    910         }
    911 
    912 
    913         /**
    914          * @ticket 45749
    915          * @ticket 47599
    916          */
    917         public function test_sites_pre_query_filter_should_bypass_database_query() {
    918             global $wpdb;
    919 
    920             add_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
    921 
    922             $num_queries = $wpdb->num_queries;
    923 
    924             $q       = new WP_Site_Query();
    925             $results = $q->query( array() );
    926 
    927             remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
    928 
    929             // Make sure no queries were executed.
    930             $this->assertSame( $num_queries, $wpdb->num_queries );
    931 
    932             // We manually inserted a non-existing site and overrode the results with it.
    933             $this->assertSame( array( 555 ), $results );
    934 
    935             // Make sure manually setting found_sites doesn't get overwritten.
    936             $this->assertSame( 1, $q->found_sites );
    937         }
    938 
    939         public static function filter_sites_pre_query( $sites, $query ) {
    940             $query->found_sites = 1;
    941 
    942             return array( 555 );
    943910        }
    944911
     
    10971064            );
    10981065        }
     1066
     1067        /**
     1068         * @ticket 45749
     1069         * @ticket 47599
     1070         */
     1071        public function test_sites_pre_query_filter_should_bypass_database_query() {
     1072            global $wpdb;
     1073
     1074            add_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
     1075
     1076            $num_queries = $wpdb->num_queries;
     1077
     1078            $q       = new WP_Site_Query();
     1079            $results = $q->query( array() );
     1080
     1081            remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
     1082
     1083            // Make sure no queries were executed.
     1084            $this->assertSame( $num_queries, $wpdb->num_queries );
     1085
     1086            // We manually inserted a non-existing site and overrode the results with it.
     1087            $this->assertSame( array( 555 ), $results );
     1088
     1089            // Make sure manually setting found_sites doesn't get overwritten.
     1090            $this->assertSame( 1, $q->found_sites );
     1091        }
     1092
     1093        public static function filter_sites_pre_query( $sites, $query ) {
     1094            $query->found_sites = 1;
     1095
     1096            return array( 555 );
     1097        }
    10991098    }
    11001099
Note: See TracChangeset for help on using the changeset viewer.