Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions tests/phpunit/tests/theme/wpThemeJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -3595,6 +3595,66 @@ public function test_get_styles_for_block_with_content_width() {
$this->assertSame( $expected, $root_rules . $style_rules );
}

/**
* @ticket 57583
*/
public function test_get_styles_for_block_with_style_variations() {
$theme_json = new WP_Theme_JSON(
array(
'version' => 2,
'styles' => array(
'blocks' => array(
'core/quote' => array(
'variations' => array(
'plain' => array(
'color' => array(
'background' => 'hotpink',
),
'unregisteredProperty' => 'value'
),
),
),
),
),
),
);

// Validate structure is sanitized.
$expected_theme_json = array(
'version' => 2,
'styles' => array(
'blocks' => array(
'core/quote' => array(
'variations' => array(
'plain' => array(
'color' => array(
'background' => 'hotpink',
),
),
),
),
),
),
);
$sanitized_theme_json = $theme_json->get_raw_data();
$this->assertEqualSetsWithIndex( $expected_theme_json, $sanitized_theme_json );

// Validate styles are generated properly.
$metadata = array(
'path' => array( 'styles', 'blocks', 'core/quote' ),
'selector' => '.wp-block-quote',
'variations' => array(
array(
'path' => array( 'styles', 'blocks', 'core/quote', 'variations', 'plain' ),
'selector' => '.is-style-plain.is-style-plain.wp-block-quote',
),
),
);
$expected_styles = '.is-style-plain .is-style-plain .wp-block-quote{background-color: hotpink;}';
$actual_styles = $theme_json->get_styles_for_block( $metadata );
$this->assertSame( $expected_styles, $actual_styles );
}

/**
* @ticket 56611
*/
Expand Down