Skip to content

Commit f5ca52c

Browse files
Tests: Remove the ::append_to_selector() method from Tests_Theme_wpThemeJson.
The method exists in the `WP_Theme_JSON` class and appears to be erroneously duplicated in the test class. Add a unit test that was meant to be included instead, as per WordPress/gutenberg#32190. Follow-up to [51051]. See #52991. git-svn-id: https://develop.svn.wordpress.org/trunk@51054 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d8c4ba3 commit f5ca52c

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

tests/phpunit/tests/theme/wpThemeJson.php

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,33 @@ function test_get_stylesheet() {
170170
);
171171
}
172172

173+
function test_get_stylesheet_preset_classes_work_with_compounded_selectors() {
174+
$theme_json = new WP_Theme_JSON(
175+
array(
176+
'version' => WP_Theme_JSON::LATEST_SCHEMA,
177+
'settings' => array(
178+
'blocks' => array(
179+
'core/heading' => array(
180+
'color' => array(
181+
'palette' => array(
182+
array(
183+
'slug' => 'white',
184+
'color' => '#fff',
185+
),
186+
),
187+
),
188+
),
189+
),
190+
),
191+
)
192+
);
193+
194+
$this->assertEquals(
195+
'h1.has-white-color,h2.has-white-color,h3.has-white-color,h4.has-white-color,h5.has-white-color,h6.has-white-color{color: #fff !important;}h1.has-white-background-color,h2.has-white-background-color,h3.has-white-background-color,h4.has-white-background-color,h5.has-white-background-color,h6.has-white-background-color{background-color: #fff !important;}',
196+
$theme_json->get_stylesheet( 'block_styles' )
197+
);
198+
}
199+
173200
function test_get_stylesheet_preset_rules_come_after_block_rules() {
174201
$theme_json = new WP_Theme_JSON(
175202
array(
@@ -619,28 +646,6 @@ function test_get_editor_settings_no_theme_support() {
619646
$this->assertEqualSetsWithIndex( $expected, $actual );
620647
}
621648

622-
/**
623-
* Function that appends a sub-selector to a existing one.
624-
*
625-
* Given the compounded $selector "h1, h2, h3"
626-
* and the $to_append selector ".some-class" the result will be
627-
* "h1.some-class, h2.some-class, h3.some-class".
628-
*
629-
* @param string $selector Original selector.
630-
* @param string $to_append Selector to append.
631-
*
632-
* @return string
633-
*/
634-
private static function append_to_selector( $selector, $to_append ) {
635-
$new_selectors = array();
636-
$selectors = explode( ',', $selector );
637-
foreach ( $selectors as $sel ) {
638-
$new_selectors[] = $sel . $to_append;
639-
}
640-
641-
return implode( ',', $new_selectors );
642-
}
643-
644649
/**
645650
* @ticket 52991
646651
*/

0 commit comments

Comments
 (0)