Make WordPress Core


Ignore:
Timestamp:
05/11/2023 10:05:51 AM (21 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/rest-api/rest-tags-controller.php

    r55457 r55745  
    13371337     */
    13381338    public function test_object_term_queries_are_cached() {
    1339         global $wpdb;
    1340 
    13411339        $tags = self::factory()->tag->create_many( 2 );
    13421340        $p    = self::factory()->post->create();
     
    13501348        unset( $request, $response );
    13511349
    1352         $num_queries = $wpdb->num_queries;
     1350        $num_queries = get_num_queries();
    13531351
    13541352        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
     
    13581356
    13591357        $this->assertSameSets( $found_1, $found_2 );
    1360         $this->assertSame( $num_queries, $wpdb->num_queries );
     1358        $this->assertSame( $num_queries, get_num_queries() );
    13611359    }
    13621360
Note: See TracChangeset for help on using the changeset viewer.