File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ public function set_up() {
1616 global $ post ;
1717
1818 parent ::set_up ();
19+ $ this ->original_stylesheet = get_stylesheet ();
1920
2021 remove_action ( 'wp_print_styles ' , 'print_emoji_styles ' );
2122
@@ -51,6 +52,11 @@ public function tear_down() {
5152 $ wp_rest_server = null ;
5253 global $ post_ID ;
5354 $ post_ID = null ;
55+
56+ if ( get_stylesheet () !== $ this ->original_stylesheet ) {
57+ switch_theme ( $ this ->original_stylesheet );
58+ }
59+
5460 parent ::tear_down ();
5561 }
5662
@@ -64,6 +70,13 @@ public function tear_down() {
6470 */
6571 protected $ original_wp_styles ;
6672
73+ /**
74+ * Original stylesheet.
75+ *
76+ * @var string
77+ */
78+ private $ original_stylesheet ;
79+
6780 public function filter_set_block_categories_post ( $ block_categories , $ post ) {
6881 if ( empty ( $ post ) ) {
6982 return $ block_categories ;
Original file line number Diff line number Diff line change @@ -18,10 +18,18 @@ class Tests_Get_Block_Asset_Url extends WP_UnitTestCase {
1818 */
1919 private $ orig_theme_dir ;
2020
21+ /**
22+ * Original stylesheet.
23+ *
24+ * @var string
25+ */
26+ private $ original_stylesheet ;
27+
2128 public function set_up () {
2229 global $ wp_theme_directories ;
2330
2431 parent ::set_up ();
32+ $ this ->original_stylesheet = get_stylesheet ();
2533
2634 // Sets up the `wp-content/themes/` directory to ensure consistency when running tests.
2735 $ this ->orig_theme_dir = $ wp_theme_directories ;
@@ -34,6 +42,10 @@ public function set_up() {
3442 public function tear_down () {
3543 global $ wp_theme_directories ;
3644
45+ if ( get_stylesheet () !== $ this ->original_stylesheet ) {
46+ switch_theme ( $ this ->original_stylesheet );
47+ }
48+
3749 $ wp_theme_directories = $ this ->orig_theme_dir ;
3850
3951 wp_clean_themes_cache ();
Original file line number Diff line number Diff line change @@ -9,6 +9,13 @@ class Tests_Blocks_GetBlockTemplates extends WP_UnitTestCase {
99
1010 const TEST_THEME = 'block-theme ' ;
1111
12+ /**
13+ * Original stylesheet.
14+ *
15+ * @var string
16+ */
17+ private $ original_stylesheet ;
18+
1219 /**
1320 * @var WP_Post
1421 */
@@ -91,9 +98,18 @@ public static function wpTearDownAfterClass() {
9198
9299 public function set_up () {
93100 parent ::set_up ();
101+ $ this ->original_stylesheet = get_stylesheet ();
94102 switch_theme ( self ::TEST_THEME );
95103 }
96104
105+ public function tear_down () {
106+ if ( get_stylesheet () !== $ this ->original_stylesheet ) {
107+ switch_theme ( $ this ->original_stylesheet );
108+ }
109+
110+ parent ::tear_down ();
111+ }
112+
97113 /**
98114 * Gets the template IDs from the given array.
99115 *
Original file line number Diff line number Diff line change @@ -16,6 +16,18 @@ class Tests_Blocks_GetHookedBlocks extends WP_UnitTestCase {
1616
1717 const TEST_THEME_NAME = 'block-theme-with-hooked-blocks ' ;
1818
19+ /**
20+ * Original stylesheet.
21+ *
22+ * @var string
23+ */
24+ private $ original_stylesheet ;
25+
26+ public function set_up () {
27+ parent ::set_up ();
28+ $ this ->original_stylesheet = get_stylesheet ();
29+ }
30+
1931 /**
2032 * Tear down after each test.
2133 *
@@ -43,6 +55,10 @@ public function tear_down() {
4355 }
4456 }
4557
58+ if ( get_stylesheet () !== $ this ->original_stylesheet ) {
59+ switch_theme ( $ this ->original_stylesheet );
60+ }
61+
4662 parent ::tear_down ();
4763 }
4864
Original file line number Diff line number Diff line change @@ -20,6 +20,13 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
2020 */
2121 protected $ original_wp_styles ;
2222
23+ /**
24+ * Original stylesheet.
25+ *
26+ * @var string
27+ */
28+ private $ original_stylesheet ;
29+
2330 /**
2431 * ID for a test post.
2532 *
@@ -61,6 +68,7 @@ public function render_stub() {}
6168 */
6269 public function set_up () {
6370 parent ::set_up ();
71+ $ this ->original_stylesheet = get_stylesheet ();
6472
6573 global $ wp_scripts , $ wp_styles ;
6674 $ this ->original_wp_scripts = $ wp_scripts ;
@@ -96,6 +104,10 @@ public function tear_down() {
96104 $ wp_scripts = $ this ->original_wp_scripts ;
97105 $ wp_styles = $ this ->original_wp_styles ;
98106
107+ if ( get_stylesheet () !== $ this ->original_stylesheet ) {
108+ switch_theme ( $ this ->original_stylesheet );
109+ }
110+
99111 parent ::tear_down ();
100112 }
101113
Original file line number Diff line number Diff line change @@ -27,6 +27,13 @@ class Tests_Blocks_wpBlockPatternsRegistry extends WP_UnitTestCase {
2727 */
2828 private $ original_registered_patterns = null ;
2929
30+ /**
31+ * Original stylesheet.
32+ *
33+ * @var string
34+ */
35+ private $ original_stylesheet ;
36+
3037 /**
3138 * Set up each test method.
3239 *
@@ -37,6 +44,7 @@ public function set_up() {
3744
3845 $ this ->registry = new WP_Block_Patterns_Registry ();
3946 $ this ->original_registered_patterns = $ this ->get_registered_patterns_variable_value ();
47+ $ this ->original_stylesheet = get_stylesheet ();
4048 }
4149
4250 /**
@@ -54,6 +62,11 @@ public function tear_down() {
5462 }
5563
5664 $ this ->set_registered_patterns_variable_value ( $ this ->original_registered_patterns );
65+
66+ if ( get_stylesheet () !== $ this ->original_stylesheet ) {
67+ switch_theme ( $ this ->original_stylesheet );
68+ }
69+
5770 parent ::tear_down ();
5871 }
5972
Original file line number Diff line number Diff line change @@ -19,14 +19,27 @@ class Tests_Theme_WPThemeGetBlockPatterns extends WP_UnitTestCase {
1919 */
2020 private $ initial_cache_object ;
2121
22+ /**
23+ * Original stylesheet.
24+ *
25+ * @var string
26+ */
27+ private $ original_stylesheet ;
28+
2229 public function set_up () {
2330 parent ::set_up ();
2431
2532 $ this ->initial_cache_object = wp_using_ext_object_cache ();
33+ $ this ->original_stylesheet = get_stylesheet ();
2634 }
2735
2836 public function tear_down () {
2937 wp_using_ext_object_cache ( $ this ->initial_cache_object );
38+
39+ if ( get_stylesheet () !== $ this ->original_stylesheet ) {
40+ switch_theme ( $ this ->original_stylesheet );
41+ }
42+
3043 parent ::tear_down ();
3144 }
3245
You can’t perform that action at this time.
0 commit comments