From 274bc8b0ec9253c3bd50aa0153d02c1706a8237e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 25 Feb 2021 11:10:46 +0000 Subject: [PATCH] Tests: Reset current screen after setting it to `dashboard` in `add_submenu_page()` tests. This avoids polluting other tests and allows the `ms-excluded` test group to successfully run on its own. Props johnbillion, SergeyBiryukov. See #52607. git-svn-id: https://develop.svn.wordpress.org/trunk@50433 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/admin/includesPlugin.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php index d880e240c9..aacccbefd3 100644 --- a/tests/phpunit/tests/admin/includesPlugin.php +++ b/tests/phpunit/tests/admin/includesPlugin.php @@ -89,6 +89,8 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { // Clean up the temporary user. wp_delete_user( $admin_user ); + // Reset current screen. + set_current_screen( 'front' ); // Verify the menu was inserted at the expected position. $this->assertSame( 'custom-position', $submenu[ $parent ][ $expected_position ][2] ); @@ -197,6 +199,8 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { // Clean up the temporary user. wp_delete_user( $admin_user ); + // Reset current screen. + set_current_screen( 'front' ); foreach ( $actual_positions as $test => $actual_position ) { // Verify the menu was inserted at the expected position. @@ -280,6 +284,8 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { // Clean up the temporary user. wp_set_current_user( $current_user ); wp_delete_user( $admin_user ); + // Reset current screen. + set_current_screen( 'front' ); // Verify the menu was inserted at the expected position. $this->assertSame( 'main_slug', $submenu['main_slug'][0][2] ); @@ -311,6 +317,8 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { // Clean up the temporary user. wp_set_current_user( $current_user ); wp_delete_user( $admin_user ); + // Reset current screen. + set_current_screen( 'front' ); // Verify the menu was inserted at the expected position. $this->assertSame( 'submenu_page_1', $submenu['main_slug'][1][2] );