diff --git a/tests/phpunit/data/themedir1/fse/theme.json b/tests/phpunit/data/themedir1/fse/theme.json index bda2c76463..b6452a9369 100644 --- a/tests/phpunit/data/themedir1/fse/theme.json +++ b/tests/phpunit/data/themedir1/fse/theme.json @@ -14,7 +14,32 @@ "color": "#000" } ], - "custom": false + "gradients": [ + { + "name": "Custom gradient", + "gradient": "linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%)", + "slug": "custom-gradient" + } + ], + "custom": false, + "customGradient": false + }, + "typography": { + "fontSizes": [ + { + "name": "Custom", + "slug": "custom", + "size": "100px" + } + ], + "customFontSize": false, + "customLineHeight": true + }, + "spacing": { + "units": [ + "rem" + ], + "customPadding": true }, "blocks": { "core/paragraph": { diff --git a/tests/phpunit/tests/blocks/block-editor.php b/tests/phpunit/tests/blocks/block-editor.php index 4d4fe7b3b5..b1bda39abd 100644 --- a/tests/phpunit/tests/blocks/block-editor.php +++ b/tests/phpunit/tests/blocks/block-editor.php @@ -343,6 +343,70 @@ class WP_Test_Block_Editor extends WP_UnitTestCase { $this->assertSame( 12345, $settings['maxUploadFileSize'] ); } + /** + * @ticket 53458 + */ + function test_get_block_editor_settings_theme_json_settings() { + switch_theme( 'fse' ); + + $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) ); + + $settings = get_block_editor_settings( array(), $post_editor_context ); + + // Related entry in theme.json: settings.color.palette + $this->assertSameSetsWithIndex( + array( + array( + 'slug' => 'light', + 'name' => 'Light', + 'color' => '#f5f7f9', + ), + array( + 'slug' => 'dark', + 'name' => 'Dark', + 'color' => '#000', + ), + ), + $settings['colors'] + ); + // settings.color.gradients + $this->assertSameSetsWithIndex( + array( + array( + 'name' => 'Custom gradient', + 'gradient' => 'linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%)', + 'slug' => 'custom-gradient', + ), + ), + $settings['gradients'] + ); + // settings.typography.fontSizes + $this->assertSameSetsWithIndex( + array( + array( + 'name' => 'Custom', + 'slug' => 'custom', + 'size' => '100px', + ), + ), + $settings['fontSizes'] + ); + // settings.color.custom + $this->assertTrue( $settings['disableCustomColors'] ); + // settings.color.customGradient + $this->assertTrue( $settings['disableCustomGradients'] ); + // settings.typography.customFontSize + $this->assertTrue( $settings['disableCustomFontSizes'] ); + // settings.typography.customLineHeight + $this->assertTrue( $settings['enableCustomLineHeight'] ); + // settings.spacing.enableCustomUnits + $this->assertSameSets( array( 'rem' ), $settings['enableCustomUnits'] ); + // settings.spacing.customPadding + $this->assertTrue( $settings['enableCustomSpacing'] ); + + switch_theme( WP_DEFAULT_THEME ); + } + /** * @ticket 52920 * @expectedDeprecated block_editor_settings diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php index 469aca1b4e..4923a1b636 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -108,8 +108,8 @@ class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase { $this->assertSame( wp_get_theme()->get( 'TextDomain' ), 'fse' ); $this->assertSame( array( - 'color' => array( - 'palette' => array( + 'color' => array( + 'palette' => array( 'theme' => array( array( 'slug' => 'light', @@ -123,9 +123,38 @@ class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase { ), ), ), - 'custom' => false, + 'gradients' => array( + 'theme' => array( + array( + 'name' => 'Custom gradient', + 'gradient' => 'linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%)', + 'slug' => 'custom-gradient', + ), + ), + ), + 'custom' => false, + 'customGradient' => false, ), - 'blocks' => array( + 'typography' => array( + 'fontSizes' => array( + 'theme' => array( + array( + 'name' => 'Custom', + 'slug' => 'custom', + 'size' => '100px', + ), + ), + ), + 'customFontSize' => false, + 'customLineHeight' => true, + ), + 'spacing' => array( + 'units' => array( + 'rem', + ), + 'customPadding' => true, + ), + 'blocks' => array( 'core/paragraph' => array( 'color' => array( 'palette' => array(