Make WordPress Core


Ignore:
Timestamp:
07/11/2023 01:31:03 PM (11 months ago)
Author:
joemcgill
Message:

Build/Test Tools: Reset main query object after each test.

This resets the main query variable, $wp_the_query during the WP_UnitTestCase_Base::tear_down method that runs after each PHPUnit test. This ensures any changes to the main query object is reset after each test to avoid cross contamination between tests, similar to how other globals are reset.

Props flixos90, spacedmonkey, joemcgill.
Fixes #58776.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/isTerm.php

    r52010 r56212  
    2626        parent::set_up();
    2727
    28         $GLOBALS['wp_the_query'] = new WP_Query();
    29         $GLOBALS['wp_query']     = $GLOBALS['wp_the_query'];
    30 
    3128        $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    3229
Note: See TracChangeset for help on using the changeset viewer.