mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-29 15:44:27 +00:00
Tests: Expand tests for get_block_editor_settings().
This adds unit tests to ensure `get_block_editor_settings()` properly maps some previously experimental features to their correct locations in the array of contextualized block editor settings returned by the function. Follow up to [51149], [51213]. Props felipeelia. Fixes #53458. git-svn-id: https://develop.svn.wordpress.org/trunk@51369 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user