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/admin/includesPlugin.php

    r51397 r51419  
    9898                // Clean up the temporary user.
    9999                wp_delete_user( $admin_user );
    100                 // Reset current screen.
    101                 set_current_screen( 'front' );
    102100
    103101                // Verify the menu was inserted at the expected position.
     
    208206                // Clean up the temporary user.
    209207                wp_delete_user( $admin_user );
    210                 // Reset current screen.
    211                 set_current_screen( 'front' );
    212208
    213209                foreach ( $actual_positions as $test => $actual_position ) {
     
    293289                wp_set_current_user( $current_user );
    294290                wp_delete_user( $admin_user );
    295                 // Reset current screen.
    296                 set_current_screen( 'front' );
    297291
    298292                // Verify the menu was inserted at the expected position.
     
    326320                wp_set_current_user( $current_user );
    327321                wp_delete_user( $admin_user );
    328                 // Reset current screen.
    329                 set_current_screen( 'front' );
    330322
    331323                // Verify the menu was inserted at the expected position.
Note: See TracChangeset for help on using the changeset viewer.