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/option/wpLoadAlloptions.php

    r55256 r55745  
    3535     */
    3636    public function test_if_alloptions_are_retrieved_from_cache() {
    37         global $wpdb;
    38         $before = $wpdb->num_queries;
     37        $before = get_num_queries();
    3938        wp_load_alloptions();
    40         $after = $wpdb->num_queries;
     39        $after = get_num_queries();
    4140
    4241        // Database has not been hit.
     
    5049     */
    5150    public function test_if_alloptions_are_retrieved_from_database() {
    52         global $wpdb;
    53 
    5451        // Delete the existing cache first.
    5552        wp_cache_delete( 'alloptions', 'options' );
    5653
    57         $before = $wpdb->num_queries;
     54        $before = get_num_queries();
    5855        wp_load_alloptions();
    59         $after = $wpdb->num_queries;
     56        $after = get_num_queries();
    6057
    6158        // Database has been hit.
Note: See TracChangeset for help on using the changeset viewer.