Make WordPress Core


Ignore:
Timestamp:
05/11/2023 10:05:51 AM (3 years 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/getPostClass.php

    r51568 r55745  
    122122     */
    123123    public function test_taxonomy_classes_hit_cache() {
    124         global $wpdb;
    125 
    126124        register_taxonomy( 'wptests_tax', 'post' );
    127125        wp_set_post_terms( $this->post_id, array( 'foo', 'bar' ), 'wptests_tax' );
     
    132130        update_meta_cache( 'post', $this->post_id );
    133131
    134         $num_queries = $wpdb->num_queries;
     132        $num_queries = get_num_queries();
    135133
    136134        $found = get_post_class( '', $this->post_id );
    137135
    138         $this->assertSame( $num_queries, $wpdb->num_queries );
     136        $this->assertSame( $num_queries, get_num_queries() );
    139137    }
    140138}
Note: See TracChangeset for help on using the changeset viewer.