Make WordPress Core

Changeset 51369


Ignore:
Timestamp:
07/07/2021 02:12:46 PM (4 years ago)
Author:
desrosj
Message:

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.

Location:
trunk/tests/phpunit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/data/themedir1/fse/theme.json

    r50960 r51369  
    1515                }
    1616            ],
    17             "custom": false
     17            "gradients": [
     18                {
     19                    "name": "Custom gradient",
     20                    "gradient": "linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%)",
     21                    "slug": "custom-gradient"
     22                }
     23            ],
     24            "custom": false,
     25            "customGradient": false
     26        },
     27        "typography": {
     28            "fontSizes": [
     29                {
     30                    "name": "Custom",
     31                    "slug": "custom",
     32                    "size": "100px"
     33                }
     34            ],
     35            "customFontSize": false,
     36            "customLineHeight": true
     37        },
     38        "spacing": {
     39            "units": [
     40                "rem"
     41            ],
     42            "customPadding": true
    1843        },
    1944        "blocks": {
  • trunk/tests/phpunit/tests/blocks/block-editor.php

    r51331 r51369  
    345345
    346346    /**
     347     * @ticket 53458
     348     */
     349    function test_get_block_editor_settings_theme_json_settings() {
     350        switch_theme( 'fse' );
     351
     352        $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
     353
     354        $settings = get_block_editor_settings( array(), $post_editor_context );
     355
     356        // Related entry in theme.json: settings.color.palette
     357        $this->assertSameSetsWithIndex(
     358            array(
     359                array(
     360                    'slug'  => 'light',
     361                    'name'  => 'Light',
     362                    'color' => '#f5f7f9',
     363                ),
     364                array(
     365                    'slug'  => 'dark',
     366                    'name'  => 'Dark',
     367                    'color' => '#000',
     368                ),
     369            ),
     370            $settings['colors']
     371        );
     372        // settings.color.gradients
     373        $this->assertSameSetsWithIndex(
     374            array(
     375                array(
     376                    'name'     => 'Custom gradient',
     377                    'gradient' => 'linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%)',
     378                    'slug'     => 'custom-gradient',
     379                ),
     380            ),
     381            $settings['gradients']
     382        );
     383        // settings.typography.fontSizes
     384        $this->assertSameSetsWithIndex(
     385            array(
     386                array(
     387                    'name' => 'Custom',
     388                    'slug' => 'custom',
     389                    'size' => '100px',
     390                ),
     391            ),
     392            $settings['fontSizes']
     393        );
     394        // settings.color.custom
     395        $this->assertTrue( $settings['disableCustomColors'] );
     396        // settings.color.customGradient
     397        $this->assertTrue( $settings['disableCustomGradients'] );
     398        // settings.typography.customFontSize
     399        $this->assertTrue( $settings['disableCustomFontSizes'] );
     400        // settings.typography.customLineHeight
     401        $this->assertTrue( $settings['enableCustomLineHeight'] );
     402        // settings.spacing.enableCustomUnits
     403        $this->assertSameSets( array( 'rem' ), $settings['enableCustomUnits'] );
     404        // settings.spacing.customPadding
     405        $this->assertTrue( $settings['enableCustomSpacing'] );
     406
     407        switch_theme( WP_DEFAULT_THEME );
     408    }
     409
     410    /**
    347411     * @ticket 52920
    348412     * @expectedDeprecated block_editor_settings
  • trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php

    r51287 r51369  
    109109        $this->assertSame(
    110110            array(
    111                 'color'  => array(
    112                     'palette' => array(
     111                'color'      => array(
     112                    'palette'        => array(
    113113                        'theme' => array(
    114114                            array(
     
    124124                        ),
    125125                    ),
    126                     'custom'  => false,
     126                    'gradients'      => array(
     127                        'theme' => array(
     128                            array(
     129                                'name'     => 'Custom gradient',
     130                                'gradient' => 'linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%)',
     131                                'slug'     => 'custom-gradient',
     132                            ),
     133                        ),
     134                    ),
     135                    'custom'         => false,
     136                    'customGradient' => false,
    127137                ),
    128                 'blocks' => array(
     138                'typography' => array(
     139                    'fontSizes'        => array(
     140                        'theme' => array(
     141                            array(
     142                                'name' => 'Custom',
     143                                'slug' => 'custom',
     144                                'size' => '100px',
     145                            ),
     146                        ),
     147                    ),
     148                    'customFontSize'   => false,
     149                    'customLineHeight' => true,
     150                ),
     151                'spacing'    => array(
     152                    'units'         => array(
     153                        'rem',
     154                    ),
     155                    'customPadding' => true,
     156                ),
     157                'blocks'     => array(
    129158                    'core/paragraph' => array(
    130159                        'color' => array(
Note: See TracChangeset for help on using the changeset viewer.