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 .


git-svn-id: https://develop.svn.wordpress.org/trunk@58295 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe McGill 2024-06-03 15:03:18 +00:00
parent 89bec7acd8
commit 2d7ec3bf3b
2 changed files with 3 additions and 0 deletions

@ -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();

@ -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();