From 2d7ec3bf3ba56609deb6cf1ec7978e23a0a0ed90 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Mon, 3 Jun 2024 15:03:18 +0000 Subject: [PATCH] Build/Test Tools: Reduce cross-pollution in `Tests_Theme_WpAddGlobalStylesForBlocks`. This ensures cached Theme JSON data is cleared between all test classes that extend `WP_Theme_UnitTestCase` and fixes a few tests that would fail in isolation, even though they full test suite would pass. Props isabel_brison, thekt12, joemcgill. Fixes #61337. git-svn-id: https://develop.svn.wordpress.org/trunk@58295 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/theme/base.php | 1 + tests/phpunit/tests/theme/wpAddGlobalStylesForBlocks.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/tests/phpunit/tests/theme/base.php b/tests/phpunit/tests/theme/base.php index 182efa5df8..4c42fa3363 100644 --- a/tests/phpunit/tests/theme/base.php +++ b/tests/phpunit/tests/theme/base.php @@ -44,6 +44,7 @@ abstract class WP_Theme_UnitTestCase extends WP_UnitTestCase { remove_filter( 'template_root', array( $this, 'filter_set_theme_root' ) ); wp_clean_themes_cache(); + wp_clean_theme_json_cache(); unset( $GLOBALS['wp_themes'] ); parent::tear_down(); diff --git a/tests/phpunit/tests/theme/wpAddGlobalStylesForBlocks.php b/tests/phpunit/tests/theme/wpAddGlobalStylesForBlocks.php index 9814a6ae68..7d34e8d2a6 100644 --- a/tests/phpunit/tests/theme/wpAddGlobalStylesForBlocks.php +++ b/tests/phpunit/tests/theme/wpAddGlobalStylesForBlocks.php @@ -131,6 +131,7 @@ class Tests_Theme_WpAddGlobalStylesForBlocks extends WP_Theme_UnitTestCase { * @ticket 61165 */ public function test_blocks_inline_styles_get_rendered() { + $this->set_up_third_party_block(); wp_register_style( 'global-styles', false, array(), true, true ); wp_enqueue_style( 'global-styles' ); wp_add_global_styles_for_blocks(); @@ -174,6 +175,7 @@ class Tests_Theme_WpAddGlobalStylesForBlocks extends WP_Theme_UnitTestCase { * @ticket 61165 */ public function test_third_party_blocks_inline_styles_for_elements_get_rendered() { + $this->set_up_third_party_block(); wp_register_style( 'global-styles', false, array(), true, true ); wp_enqueue_style( 'global-styles' ); wp_add_global_styles_for_blocks();