Make WordPress Core


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

    r52921 r55745  
    321321     */
    322322    public function test_term_exists_caching() {
    323         global $wpdb;
    324323        register_taxonomy( 'wptests_tax', 'post' );
    325324
     
    332331        );
    333332        $this->assertEquals( $t, term_exists( $slug ) );
    334         $num_queries = $wpdb->num_queries;
     333        $num_queries = get_num_queries();
    335334        $this->assertEquals( $t, term_exists( $slug ) );
    336         $this->assertSame( $num_queries, $wpdb->num_queries );
     335        $this->assertSame( $num_queries, get_num_queries() );
    337336
    338337        $this->assertTrue( wp_delete_term( $t, 'wptests_tax' ) );
    339         $num_queries = $wpdb->num_queries;
     338        $num_queries = get_num_queries();
    340339        $this->assertNull( term_exists( $slug ) );
    341         $this->assertSame( $num_queries + 2, $wpdb->num_queries );
     340        $this->assertSame( $num_queries + 2, get_num_queries() );
    342341
    343342        // Clean up.
     
    350349     */
    351350    public function test_term_exists_caching_suspend_cache_invalidation() {
    352         global $wpdb;
    353351        register_taxonomy( 'wptests_tax', 'post' );
    354352
     
    363361
    364362        $this->assertEquals( $t, term_exists( $slug ) );
    365         $num_queries = $wpdb->num_queries;
     363        $num_queries = get_num_queries();
    366364        $this->assertEquals( $t, term_exists( $slug ) );
    367         $this->assertSame( $num_queries + 1, $wpdb->num_queries );
     365        $this->assertSame( $num_queries + 1, get_num_queries() );
    368366        wp_suspend_cache_invalidation( false );
    369367
Note: See TracChangeset for help on using the changeset viewer.