Make WordPress Core


Ignore:
Timestamp:
06/14/2024 09:03:40 AM (2 years ago)
Author:
oandregal
Message:

Section styles: add slug to override non-kebab-cased variations.

Props aaronrobertshaw, oandregal.
Fixes #61440.

File:
1 edited

Legend:

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

    r58394 r58413  
    6262         *
    6363         * @ticket 61312
     64         * @ticket 61440
    6465         */
    6566        public function test_add_registered_block_styles_to_theme_data() {
     
    99100                );
    100101
     102                /*
     103                 * This style is to be deliberately overwritten by the theme.json partial
     104                 * See `tests/phpunit/data/themedir1/block-theme/styles/block-style-variation-with-slug.json`.
     105                 */
     106                register_block_style(
     107                        'core/group',
     108                        array(
     109                                'name'       => 'WithSlug',
     110                                'style_data' => array(
     111                                        'color' => array(
     112                                                'background' => 'whitesmoke',
     113                                                'text'       => 'black',
     114                                        ),
     115                                ),
     116                        )
     117                );
    101118                register_block_style(
    102119                        'core/group',
     
    111128                $expected     = array(
    112129                        'variations' => array(
     130                                // @ticket 61440
     131                                'WithSlug'                => array(
     132                                        'color' => array(
     133                                                'background' => 'aliceblue',
     134                                                'text'       => 'midnightblue',
     135                                        ),
     136                                ),
    113137                                'my-variation'            => $variation_styles_data,
    114138
     
    134158
    135159                unregister_block_style( 'core/group', 'my-variation' );
     160                unregister_block_style( 'core/group', 'WithSlug' );
    136161
    137                 $this->assertSameSetsWithIndex( $group_styles, $expected );
     162                $this->assertSameSetsWithIndex( $expected, $group_styles );
    138163        }
    139164}
Note: See TracChangeset for help on using the changeset viewer.