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/query/commentFeed.php

    r53941 r55745  
    2929     */
    3030    public function test_archive_comment_feed() {
    31         global $wpdb;
    3231        add_filter( 'split_the_query', '__return_false' );
    3332        $q1   = new WP_Query();
     
    4342        );
    4443        $q1->query( $args );
    45         $num_queries = $wpdb->num_queries;
     44        $num_queries = get_num_queries();
    4645        $q2          = new WP_Query();
    4746        $q2->query( $args );
    4847        $this->assertTrue( $q2->is_comment_feed() );
    4948        $this->assertFalse( $q2->is_singular() );
    50         $this->assertSame( $num_queries + 1, $wpdb->num_queries );
     49        $this->assertSame( $num_queries + 1, get_num_queries() );
    5150    }
    5251
     
    8887     */
    8988    public function test_single_comment_feed() {
    90         global $wpdb;
    9189        $post = get_post( self::$post_ids[0] );
    9290
     
    104102
    105103        $q1->query( $args );
    106         $num_queries = $wpdb->num_queries;
     104        $num_queries = get_num_queries();
    107105        $q2          = new WP_Query();
    108106        $q2->query( $args );
     
    110108        $this->assertTrue( $q2->is_comment_feed() );
    111109        $this->assertTrue( $q2->is_singular() );
    112         $this->assertSame( $num_queries + 1, $wpdb->num_queries );
     110        $this->assertSame( $num_queries + 1, get_num_queries() );
    113111    }
    114112}
Note: See TracChangeset for help on using the changeset viewer.