Make WordPress Core


Ignore:
Timestamp:
05/11/2023 10:05:51 AM (19 months ago)
Author:
spacedmonkey
Message:

Tests: Use the function get_num_queries across all unit tests.

Replace use of $wpdb->num_queries with a function call to get_num_queries. This improves readability and consistency between tests.

Props SergeyBiryukov, peterwilsoncc, spacedmonkey.
See #57841.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user/query.php

    r55562 r55745  
    17211721     */
    17221722    public function test_users_pre_query_filter_should_bypass_database_query() {
    1723         global $wpdb;
    1724 
    17251723        add_filter( 'users_pre_query', array( __CLASS__, 'filter_users_pre_query' ), 10, 2 );
    17261724
    1727         $num_queries = $wpdb->num_queries;
     1725        $num_queries = get_num_queries();
    17281726        $q           = new WP_User_Query(
    17291727            array(
     
    17351733
    17361734        // Make sure no queries were executed.
    1737         $this->assertSame( $num_queries, $wpdb->num_queries );
     1735        $this->assertSame( $num_queries, get_num_queries() );
    17381736
    17391737        // We manually inserted a non-existing user and overrode the results with it.
Note: See TracChangeset for help on using the changeset viewer.