diff --git a/tests/phpunit/tests/fonts/font-face/base.php b/tests/phpunit/tests/fonts/font-face/base.php index 3b016557728a6..43c21ac3a89b3 100644 --- a/tests/phpunit/tests/fonts/font-face/base.php +++ b/tests/phpunit/tests/fonts/font-face/base.php @@ -69,6 +69,7 @@ public static function set_up_before_class() { public static function tear_down_after_class() { // Reset static flags. self::$requires_switch_theme_fixtures = false; + self::$theme_root = null; parent::tear_down_after_class(); } diff --git a/tests/phpunit/tests/fonts/font-face/wpPrintFontFacesFromStyleVariations.php b/tests/phpunit/tests/fonts/font-face/wpPrintFontFacesFromStyleVariations.php index 664404d552b45..2c35569b4d196 100644 --- a/tests/phpunit/tests/fonts/font-face/wpPrintFontFacesFromStyleVariations.php +++ b/tests/phpunit/tests/fonts/font-face/wpPrintFontFacesFromStyleVariations.php @@ -16,8 +16,9 @@ class Tests_Fonts_WpPrintFontFacesFromStyleVariations extends WP_Font_Face_UnitT const FONTS_THEME = 'fonts-block-theme'; public static function set_up_before_class() { - parent::set_up_before_class(); self::$requires_switch_theme_fixtures = true; + + parent::set_up_before_class(); } /** diff --git a/tests/phpunit/tests/rest-api/rest-block-type-controller.php b/tests/phpunit/tests/rest-api/rest-block-type-controller.php index 3cf8c5244d77c..21eb081bcf11e 100644 --- a/tests/phpunit/tests/rest-api/rest-block-type-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-type-controller.php @@ -62,8 +62,6 @@ public static function wpTearDownAfterClass() { self::delete_user( self::$admin_id ); self::delete_user( self::$subscriber_id ); unregister_block_type( 'fake/test' ); - unregister_block_type( 'fake/invalid' ); - unregister_block_type( 'fake/false' ); } /** @@ -138,7 +136,8 @@ public function test_get_item_with_styles() { wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/block-types/' . $block_name ); $response = rest_get_server()->dispatch( $request ); - $data = $response->get_data(); + unregister_block_type( $block_name ); + $data = $response->get_data(); $this->assertSameSets( array( $block_styles ), $data['styles'] ); } @@ -166,6 +165,7 @@ public function test_get_item_with_styles_merge() { wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/block-types/' . $block_name ); $response = rest_get_server()->dispatch( $request ); + unregister_block_type( $block_name ); $data = $response->get_data(); $expected = array( array( @@ -232,7 +232,8 @@ public function test_get_item_invalid() { wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/block-types/' . $block_type ); $response = rest_get_server()->dispatch( $request ); - $data = $response->get_data(); + unregister_block_type( $block_type ); + $data = $response->get_data(); $this->assertSame( $block_type, $data['name'] ); $this->assertSame( '1', $data['title'] ); $this->assertNull( $data['category'] ); @@ -311,7 +312,8 @@ public function test_get_item_defaults() { wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/block-types/' . $block_type ); $response = rest_get_server()->dispatch( $request ); - $data = $response->get_data(); + unregister_block_type( $block_type ); + $data = $response->get_data(); $this->assertSame( $block_type, $data['name'] ); $this->assertSame( '', $data['title'] ); $this->assertNull( $data['category'] ); @@ -368,7 +370,8 @@ public function test_get_item_deprecated() { wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/block-types/' . $block_type ); $response = rest_get_server()->dispatch( $request ); - $data = $response->get_data(); + unregister_block_type( $block_type ); + $data = $response->get_data(); $this->assertSameSets( array( 'hello_world' ), $data['editor_script_handles'], @@ -438,7 +441,8 @@ public function test_get_item_deprecated_with_arrays() { wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/block-types/' . $block_type ); $response = rest_get_server()->dispatch( $request ); - $data = $response->get_data(); + unregister_block_type( $block_type ); + $data = $response->get_data(); $this->assertSameSets( $settings['editor_script'], $data['editor_script_handles'], @@ -525,7 +529,8 @@ public function test_get_variation() { wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/block-types/' . $block_type ); $response = rest_get_server()->dispatch( $request ); - $data = $response->get_data(); + unregister_block_type( $block_type ); + $data = $response->get_data(); $this->assertSame( $block_type, $data['name'] ); $this->assertArrayHasKey( 'variations', $data ); $this->assertCount( 1, $data['variations'] ); @@ -868,7 +873,8 @@ public function test_variation_callback() { wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/block-types/' . $block_type ); $response = rest_get_server()->dispatch( $request ); - $data = $response->get_data(); + unregister_block_type( $block_type ); + $data = $response->get_data(); $this->assertSameSets( $this->mock_variation_callback(), $data['variations'] ); } diff --git a/tests/phpunit/tests/sitemaps/sitemaps.php b/tests/phpunit/tests/sitemaps/sitemaps.php index 85f9965245842..24243787d5068 100644 --- a/tests/phpunit/tests/sitemaps/sitemaps.php +++ b/tests/phpunit/tests/sitemaps/sitemaps.php @@ -464,15 +464,17 @@ public function test_sitemaps_enabled() { /** * @ticket 50643 - * @runInSeparateProcess - * @preserveGlobalState disabled */ public function test_disable_sitemap_should_return_404() { add_filter( 'wp_sitemaps_enabled', '__return_false' ); + // Instantiate the server before navigating: registering the sitemap + // rewrite tags is what adds `sitemap` to `$wp->public_query_vars`. + $sitemaps = wp_sitemaps_get_server(); + $this->go_to( home_url( '/?sitemap=index' ) ); - wp_sitemaps_get_server()->render_sitemaps(); + $sitemaps->render_sitemaps(); remove_filter( 'wp_sitemaps_enabled', '__return_false' ); @@ -481,8 +483,6 @@ public function test_disable_sitemap_should_return_404() { /** * @ticket 50643 - * @runInSeparateProcess - * @preserveGlobalState disabled */ public function test_empty_url_list_should_return_404() { wp_register_sitemap_provider( 'foo', new WP_Sitemaps_Empty_Test_Provider( 'foo' ) ); diff --git a/tests/phpunit/tests/widgets/wpWidgetMediaAudio.php b/tests/phpunit/tests/widgets/wpWidgetMediaAudio.php index 20aee5f30baf4..cb555fb5285a5 100644 --- a/tests/phpunit/tests/widgets/wpWidgetMediaAudio.php +++ b/tests/phpunit/tests/widgets/wpWidgetMediaAudio.php @@ -316,6 +316,9 @@ public function test_enqueue_admin_scripts() { * @covers WP_Widget_Media_Audio::render_control_template_scripts */ public function test_render_control_template_scripts() { + // Provides wp_underscore_audio_template(), normally loaded by wp_enqueue_media(). + require_once ABSPATH . WPINC . '/media-template.php'; + $widget = new WP_Widget_Media_Audio(); ob_start(); diff --git a/tests/phpunit/tests/widgets/wpWidgetMediaVideo.php b/tests/phpunit/tests/widgets/wpWidgetMediaVideo.php index aeedae2a3174f..98c86ec4865fd 100644 --- a/tests/phpunit/tests/widgets/wpWidgetMediaVideo.php +++ b/tests/phpunit/tests/widgets/wpWidgetMediaVideo.php @@ -344,6 +344,9 @@ public function test_enqueue_admin_scripts() { * @covers WP_Widget_Media_Video::render_control_template_scripts */ public function test_render_control_template_scripts() { + // Provides wp_underscore_video_template(), normally loaded by wp_enqueue_media(). + require_once ABSPATH . WPINC . '/media-template.php'; + $widget = new WP_Widget_Media_Video(); ob_start();