Skip to content

Commit

Permalink
Add another variation sanitisation test
Browse files Browse the repository at this point in the history
This test checks that when removing insecure properties an
unknown/unsupported property is removed from the variation.
  • Loading branch information
dsas committed Aug 10, 2023
1 parent ba0f0fd commit 9a468b7
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,57 @@ public function test_block_style_variations() {
$this->assertSameSetsWithIndex( $expected, $actual );
}

public function test_block_style_variations_with_invalid_properties() {
wp_set_current_user( static::$administrator_id );

$partially_invalid_variation = array(
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'styles' => array(
'blocks' => array(
'core/button' => array(
'color' => array(
'background' => 'blue',
),
'variations' => array(
'outline' => array(
'color' => array(
'background' => 'purple',
),
'invalid' => array(
'value' => 'should be stripped',
),
),
),
),
),
),
);

$expected = array(
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'styles' => array(
'blocks' => array(
'core/button' => array(
'color' => array(
'background' => 'blue',
),
'variations' => array(
'outline' => array(
'color' => array(
'background' => 'purple',
),
),
),
),
),
),
);

$actual = WP_Theme_JSON_Gutenberg::remove_insecure_properties( $partially_invalid_variation );

$this->assertSameSetsWithIndex( $expected, $actual );
}

public function test_update_separator_declarations() {
// If only background is defined, test that includes border-color to the style so it is applied on the front end.
$theme_json = new WP_Theme_JSON_Gutenberg(
Expand Down

0 comments on commit 9a468b7

Please sign in to comment.