Skip to content

Commit 3ea2641

Browse files
committed
Updated tests to reflect the changed situation:
- Before we were unsetting blockGap for block and elements from the merged $theme_json structure in sanitize(). - After we keep them in the merged $theme_json, but skip them when printing out the global stylesheet.
1 parent c61ff98 commit 3ea2641

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

phpunit/class-wp-theme-json-test.php

+35-2
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,38 @@ function test_get_stylesheet_skips_disabled_protected_properties() {
385385
$this->assertEquals( $expected, $theme_json->get_stylesheet( array( 'styles' ) ) );
386386
}
387387

388+
function test_get_stylesheet_skips_top_level_properties_at_block_level() {
389+
$theme_json = new WP_Theme_JSON_Gutenberg(
390+
array(
391+
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
392+
'settings' => array(
393+
'spacing' => array(
394+
'padding' => true,
395+
'blockGap' => true,
396+
),
397+
),
398+
'styles' => array(
399+
'spacing' => array(
400+
'padding' => '1vw',
401+
'blockGap' => '1em',
402+
),
403+
'blocks' => array(
404+
'core/columns' => array(
405+
'spacing' => array(
406+
'padding' => '0.5rem',
407+
'blockGap' => '24px',
408+
),
409+
),
410+
),
411+
),
412+
)
413+
);
414+
415+
$expected = 'body { margin: 0; }body{padding: 1vw;--wp--style--block-gap: 1em;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }.wp-site-blocks > * + * { margin-block-start: var( --wp--style--block-gap ); }.wp-block-columns{padding: 0.5rem;}';
416+
$this->assertEquals( $expected, $theme_json->get_stylesheet() );
417+
$this->assertEquals( $expected, $theme_json->get_stylesheet( array( 'styles' ) ) );
418+
}
419+
388420
function test_get_stylesheet_renders_enabled_protected_properties() {
389421
$theme_json = new WP_Theme_JSON_Gutenberg(
390422
array(
@@ -2253,7 +2285,7 @@ function test_sanitization() {
22532285
'core/group' => array(
22542286
'spacing' => array(
22552287
'margin' => 'valid value',
2256-
'blockGap' => 'invalid value',
2288+
'blockGap' => 'valid value',
22572289
),
22582290
),
22592291
),
@@ -2271,7 +2303,8 @@ function test_sanitization() {
22712303
'blocks' => array(
22722304
'core/group' => array(
22732305
'spacing' => array(
2274-
'margin' => 'valid value',
2306+
'margin' => 'valid value',
2307+
'blockGap' => 'valid value',
22752308
),
22762309
),
22772310
),

0 commit comments

Comments
 (0)