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.

git-svn-id: https://develop.svn.wordpress.org/trunk@51419 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
SergeyBiryukov
2021-07-13 16:13:01 +00:00
parent 16d538c0f8
commit 013b0c11f0
18 changed files with 24 additions and 103 deletions
-10
View File
@@ -400,8 +400,6 @@ class Tests_AdminBar extends WP_UnitTestCase {
$wp_admin_bar = $this->get_standard_admin_bar();
$node = $wp_admin_bar->get_node( 'archive' );
set_current_screen( 'front' );
$this->assertNull( $node );
}
@@ -415,8 +413,6 @@ class Tests_AdminBar extends WP_UnitTestCase {
$wp_admin_bar = $this->get_standard_admin_bar();
$node = $wp_admin_bar->get_node( 'archive' );
set_current_screen( 'front' );
$this->assertNotNull( $node );
}
@@ -429,8 +425,6 @@ class Tests_AdminBar extends WP_UnitTestCase {
$wp_admin_bar = $this->get_standard_admin_bar();
$node = $wp_admin_bar->get_node( 'archive' );
set_current_screen( 'front' );
$this->assertNull( $node );
}
@@ -508,7 +502,6 @@ class Tests_AdminBar extends WP_UnitTestCase {
$wp_admin_bar = $this->get_standard_admin_bar();
$node = $wp_admin_bar->get_node( 'archive' );
set_current_screen( 'front' );
unregister_post_type( 'foo-non-public' );
$this->assertNull( $node );
@@ -532,7 +525,6 @@ class Tests_AdminBar extends WP_UnitTestCase {
$wp_admin_bar = $this->get_standard_admin_bar();
$node = $wp_admin_bar->get_node( 'archive' );
set_current_screen( 'front' );
unregister_post_type( 'foo-non-public' );
$this->assertNull( $node );
@@ -556,7 +548,6 @@ class Tests_AdminBar extends WP_UnitTestCase {
$wp_admin_bar = $this->get_standard_admin_bar();
$node = $wp_admin_bar->get_node( 'archive' );
set_current_screen( 'front' );
unregister_post_type( 'foo-non-public' );
$this->assertNull( $node );
@@ -679,7 +670,6 @@ class Tests_AdminBar extends WP_UnitTestCase {
);
$wp_customize->start_previewing_theme();
set_current_screen( 'front' );
$wp_admin_bar = $this->get_standard_admin_bar();
$node = $wp_admin_bar->get_node( 'customize' );
$this->assertNotEmpty( $node );