Changeset 51419 for trunk/tests/phpunit/includes/abstract-testcase.php
- Timestamp:
- 07/13/2021 04:13:01 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/abstract-testcase.php
r51335 r51419 158 158 } 159 159 160 // Reset $wp_sitemap global so that sitemap-related dynamic $wp->public_query_vars are added when the next test runs. 160 /* 161 * Reset globals related to current screen to provide a consistent global starting state 162 * for tests that interact with admin screens. Replaces the need for individual tests 163 * to invoke `set_current_screen( 'front' )` (or an alternative implementation) as a reset. 164 * 165 * The globals are from `WP_Screen::set_current_screen()`. 166 * 167 * Why not invoke `set_current_screen( 'front' )`? 168 * Performance (faster test runs with less memory usage). How so? For each test, 169 * it saves creating an instance of WP_Screen, making two method calls, 170 * and firing of the `current_screen` action. 171 */ 172 $current_screen_globals = array( 'current_screen', 'taxnow', 'typenow' ); 173 foreach ( $current_screen_globals as $global ) { 174 $GLOBALS[ $global ] = null; 175 } 176 177 /* 178 * Reset $wp_sitemap global so that sitemap-related dynamic $wp->public_query_vars 179 * are added when the next test runs. 180 */ 161 181 $GLOBALS['wp_sitemaps'] = null; 162 182
Note: See TracChangeset
for help on using the changeset viewer.