Make WordPress Core


Ignore:
Timestamp:
04/05/2022 12:06:48 PM (4 years ago)
Author:
gziolo
Message:

Editor: Backport block support changes from the Gutenberg plugin

Migrate spacing, border, color, dimensions, elements and typography and associated tests for block supports in the block editor.

Related changes in Gutenberg:

Props ramonopoly, aaronrobertshaw.
See #55505.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/block-supports/typography.php

    r52264 r53076  
    6363    }
    6464
     65    /**
     66     * @ticket 55505
     67     */
     68    function test_typography_with_skipped_serialization_block_supports() {
     69        $block_name = 'test/typography-with-skipped-serialization-block-supports';
     70        register_block_type(
     71            $block_name,
     72            array(
     73                'api_version' => 2,
     74                'attributes'  => array(
     75                    'style' => array(
     76                        'type' => 'object',
     77                    ),
     78                ),
     79                'supports'    => array(
     80                    'typography' => array(
     81                        'fontSize'                        => true,
     82                        'lineHeight'                      => true,
     83                        '__experimentalFontFamily'        => true,
     84                        '__experimentalLetterSpacing'     => true,
     85                        '__experimentalSkipSerialization' => true,
     86                    ),
     87                ),
     88            )
     89        );
     90        $registry   = WP_Block_Type_Registry::get_instance();
     91        $block_type = $registry->get_registered( $block_name );
     92        $block_atts = array(
     93            'style' => array(
     94                'typography' => array(
     95                    'fontSize'      => 'serif',
     96                    'lineHeight'    => 'serif',
     97                    'fontFamily'    => '22px',
     98                    'letterSpacing' => '22px',
     99                ),
     100            ),
     101        );
     102
     103        $actual   = wp_apply_typography_support( $block_type, $block_atts );
     104        $expected = array();
     105
     106        $this->assertSame( $expected, $actual );
     107        unregister_block_type( $block_name );
     108    }
     109
     110    /**
     111     * @ticket 55505
     112     */
     113    function test_letter_spacing_with_individual_skipped_serialization_block_supports() {
     114        $block_name = 'test/letter-spacing-with-individua-skipped-serialization-block-supports';
     115        register_block_type(
     116            $block_name,
     117            array(
     118                'api_version' => 2,
     119                'attributes'  => array(
     120                    'style' => array(
     121                        'type' => 'object',
     122                    ),
     123                ),
     124                'supports'    => array(
     125                    'typography' => array(
     126                        '__experimentalLetterSpacing'     => true,
     127                        '__experimentalSkipSerialization' => array(
     128                            'letterSpacing',
     129                        ),
     130                    ),
     131                ),
     132            )
     133        );
     134        $registry   = WP_Block_Type_Registry::get_instance();
     135        $block_type = $registry->get_registered( $block_name );
     136        $block_atts = array( 'style' => array( 'typography' => array( 'letterSpacing' => '22px' ) ) );
     137
     138        $actual   = wp_apply_typography_support( $block_type, $block_atts );
     139        $expected = array();
     140
     141        $this->assertSame( $expected, $actual );
     142        unregister_block_type( $block_name );
     143    }
     144
    65145    function test_font_family_with_legacy_inline_styles_using_a_css_var() {
    66146        $block_name = 'test/font-family-with-inline-styles-using-css-var';
Note: See TracChangeset for help on using the changeset viewer.