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/term/getTheTerms.php

    r52010 r55745  
    198198     */
    199199    public function test_uncached_terms_should_be_primed_with_a_single_query() {
    200         global $wpdb;
    201 
    202200        register_taxonomy( 'wptests_tax', 'post' );
    203201
     
    211209        clean_term_cache( array( $terms[0], $terms[1] ), 'wptests_tax', false );
    212210
    213         $num_queries = $wpdb->num_queries;
     211        $num_queries = get_num_queries();
    214212        $found       = get_the_terms( self::$post_ids[0], 'wptests_tax' );
    215213
     
    217215
    218216        $num_queries++;
    219         $this->assertSame( $num_queries, $wpdb->num_queries );
     217        $this->assertSame( $num_queries, get_num_queries() );
    220218
    221219    }
Note: See TracChangeset for help on using the changeset viewer.