From 0a933569ef8a7930fafd75f5a6d54207c6acdd1c Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Mon, 9 Nov 2026 16:14:06 +0000 Subject: [PATCH 1/3] Tests: --- tests/phpunit/tests/theme/wpThemeJson.php | 64 +++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/tests/phpunit/tests/theme/wpThemeJson.php b/tests/phpunit/tests/theme/wpThemeJson.php index 70d2838984e3b..57050ee82adc5 100644 --- a/tests/phpunit/tests/theme/wpThemeJson.php +++ b/tests/phpunit/tests/theme/wpThemeJson.php @@ -51,6 +51,10 @@ public function tear_down() { unregister_block_type( 'test/feature-selector' ); } + if ( $registry->is_registered( 'test/deprecated-feature-selector' ) ) { + unregister_block_type( 'test/deprecated-feature-selector' ); + } + parent::tear_down(); } @@ -889,6 +893,66 @@ public function test_get_stylesheet_preset_css_vars_use_feature_selector() { ); } + /** + * Tests that feature selectors defined as `__experimentalSelector` inside + * the `supports` property are correctly output in the stylesheet. + */ + public function test_get_stylesheet_with_deprecated_feature_level_selectors() { + register_block_type( + 'test/deprecated-feature-selector', + array( + 'api_version' => 3, + 'supports' => array( + 'color' => array( + '__experimentalSelector' => 'h2, h3', + ), + 'typography' => array( + 'fontSize' => true, + ), + ), + ) + ); + + $theme_json = new WP_Theme_JSON( + array( + 'version' => WP_Theme_JSON::LATEST_SCHEMA, + 'settings' => array( + 'color' => array( + 'custom' => false, + 'palette' => array( + array( + 'slug' => 'green', + 'color' => 'green', + ), + ), + ), + 'typography' => array( + 'fontSize' => true, + ), + ), + 'styles' => array( + 'blocks' => array( + 'test/deprecated-feature-selector' => array( + 'color' => array( + 'text' => 'green', + ), + 'typography' => array( + 'fontSize' => '3em', + ), + ), + ), + ), + ) + ); + + $base_styles = ':root{--wp--preset--color--green: green;}'; + $block_styles = ':root :where(.wp-block-test-deprecated-feature-selector){font-size: 3em;}:root :where(.wp-block-test-deprecated-feature-selector h2, .wp-block-test-deprecated-feature-selector h3){color: green;}'; + $preset_styles = '.has-green-color{color: var(--wp--preset--color--green) !important;}.has-green-background-color{background-color: var(--wp--preset--color--green) !important;}.has-green-border-color{border-color: var(--wp--preset--color--green) !important;}'; + $expected = $base_styles . $block_styles . $preset_styles; + + $this->assertSameCSS( $expected, $theme_json->get_stylesheet( array( 'styles', 'presets', 'variables' ), null, array( 'skip_root_layout_styles' => true ) ) ); + } + /** * @ticket 53175 * @ticket 54336 From 4bb7afda4f313b1ea38daef7bcc152481fefe382 Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Tue, 10 Nov 2026 03:17:02 +0000 Subject: [PATCH 2/3] Tests: Use assertSame instead of undefined assertSameCSS. --- tests/phpunit/tests/theme/wpThemeJson.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/theme/wpThemeJson.php b/tests/phpunit/tests/theme/wpThemeJson.php index 57050ee82adc5..2badb6f4c4f59 100644 --- a/tests/phpunit/tests/theme/wpThemeJson.php +++ b/tests/phpunit/tests/theme/wpThemeJson.php @@ -950,7 +950,7 @@ public function test_get_stylesheet_with_deprecated_feature_level_selectors() { $preset_styles = '.has-green-color{color: var(--wp--preset--color--green) !important;}.has-green-background-color{background-color: var(--wp--preset--color--green) !important;}.has-green-border-color{border-color: var(--wp--preset--color--green) !important;}'; $expected = $base_styles . $block_styles . $preset_styles; - $this->assertSameCSS( $expected, $theme_json->get_stylesheet( array( 'styles', 'presets', 'variables' ), null, array( 'skip_root_layout_styles' => true ) ) ); + $this->assertSame( $expected, $theme_json->get_stylesheet( array( 'styles', 'presets', 'variables' ), null, array( 'skip_root_layout_styles' => true ) ) ); } /** From 5f179c1cddf8b7905c50194e8203427cff1d4c5f Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Tue, 10 Nov 2026 03:43:47 +0000 Subject: [PATCH 3/3] Tests: Reference Trac ticket 66640 on deprecated feature selector coverage. --- tests/phpunit/tests/theme/wpThemeJson.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/phpunit/tests/theme/wpThemeJson.php b/tests/phpunit/tests/theme/wpThemeJson.php index 2badb6f4c4f59..12feba3b3ab4f 100644 --- a/tests/phpunit/tests/theme/wpThemeJson.php +++ b/tests/phpunit/tests/theme/wpThemeJson.php @@ -896,6 +896,8 @@ public function test_get_stylesheet_preset_css_vars_use_feature_selector() { /** * Tests that feature selectors defined as `__experimentalSelector` inside * the `supports` property are correctly output in the stylesheet. + * + * @ticket 66640 */ public function test_get_stylesheet_with_deprecated_feature_level_selectors() { register_block_type(