Make WordPress Core


Ignore:
Timestamp:
05/11/2023 10:05:51 AM (20 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/post/query.php

    r55562 r55745  
    556556     */
    557557    public function test_posts_pre_query_filter_should_bypass_database_query() {
    558         global $wpdb;
    559 
    560558        add_filter( 'posts_pre_query', array( __CLASS__, 'filter_posts_pre_query' ) );
    561559
    562         $num_queries = $wpdb->num_queries;
     560        $num_queries = get_num_queries();
    563561        $q           = new WP_Query(
    564562            array(
     
    570568        remove_filter( 'posts_pre_query', array( __CLASS__, 'filter_posts_pre_query' ) );
    571569
    572         $this->assertSame( $num_queries, $wpdb->num_queries );
     570        $this->assertSame( $num_queries, get_num_queries() );
    573571        $this->assertSame( array( 12345 ), $q->posts );
    574572    }
Note: See TracChangeset for help on using the changeset viewer.