mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-14 13:50:24 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@55745 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -34,10 +34,9 @@ class Tests_Option_wpLoadAlloptions extends WP_UnitTestCase {
|
||||
* @covers ::wp_load_alloptions
|
||||
*/
|
||||
public function test_if_alloptions_are_retrieved_from_cache() {
|
||||
global $wpdb;
|
||||
$before = $wpdb->num_queries;
|
||||
$before = get_num_queries();
|
||||
wp_load_alloptions();
|
||||
$after = $wpdb->num_queries;
|
||||
$after = get_num_queries();
|
||||
|
||||
// Database has not been hit.
|
||||
$this->assertSame( $before, $after );
|
||||
@@ -49,14 +48,12 @@ class Tests_Option_wpLoadAlloptions extends WP_UnitTestCase {
|
||||
* @covers ::wp_load_alloptions
|
||||
*/
|
||||
public function test_if_alloptions_are_retrieved_from_database() {
|
||||
global $wpdb;
|
||||
|
||||
// Delete the existing cache first.
|
||||
wp_cache_delete( 'alloptions', 'options' );
|
||||
|
||||
$before = $wpdb->num_queries;
|
||||
$before = get_num_queries();
|
||||
wp_load_alloptions();
|
||||
$after = $wpdb->num_queries;
|
||||
$after = get_num_queries();
|
||||
|
||||
// Database has been hit.
|
||||
$this->assertSame( $before + 1, $after );
|
||||
|
||||
Reference in New Issue
Block a user