Make WordPress Core


Ignore:
Timestamp:
07/13/2021 04:13:01 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Reset $current_screen global between tests to avoid cross-test interdependencies.

This provides a consistent global starting state for tests that interact with admin screens.

Individual tests no longer need to invoke set_current_screen( 'front' ) (or an alternative implementation) as a reset.

Follow-up to [29251], [29860], [31046], [36721], [38678], [48908], [50433].

Props hellofromTonya, johnbillion.
Fixes #53431.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php

    r50450 r51419  
    55 */
    66class Tests_Menu_WpAjaxMenuQuickSeach extends WP_UnitTestCase {
    7 
    8     /**
    9      * Current screen.
    10      *
    11      * @var mixed
    12      */
    13     protected $current_screen;
    14 
    15     /**
    16      * Set up. Workaround set_current_screen( null ) not working due to $hook_suffix not being set.
    17      */
    18     function setUp() {
    19         parent::setUp();
    20 
    21         global $current_screen;
    22         $this->current_screen = $current_screen;
    23     }
    24 
    25     /**
    26      * Tear down. Workaround set_current_screen( null ) not working due to $hook_suffix not being set.
    27      */
    28     function tearDown() {
    29         global $current_screen;
    30         $current_screen = $this->current_screen;
    31         parent::tearDown();
    32     }
    337
    348    /**
Note: See TracChangeset for help on using the changeset viewer.