Make WordPress Core


Ignore:
Timestamp:
07/13/2021 04:13:01 PM (5 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/url.php

    r51415 r51419  
    200200
    201201        function test_home_url_from_admin() {
    202                 $screen = get_current_screen();
    203 
    204202                // Pretend to be in the site admin.
    205203                set_current_screen( 'dashboard' );
     
    244242
    245243                update_option( 'home', set_url_scheme( $home, 'http' ) );
    246 
    247                 $GLOBALS['current_screen'] = $screen;
    248244        }
    249245
    250246        function test_network_home_url_from_admin() {
    251                 $screen = get_current_screen();
    252 
    253247                // Pretend to be in the site admin.
    254248                set_current_screen( 'dashboard' );
     
    269263                $_SERVER['HTTPS'] = 'on';
    270264                $this->assertSame( $home_https, network_home_url() );
    271 
    272                 $GLOBALS['current_screen'] = $screen;
    273265        }
    274266
Note: See TracChangeset for help on using the changeset viewer.