Make WordPress Core


Ignore:
Timestamp:
01/23/2024 09:04:51 AM (9 months ago)
Author:
youknowriad
Message:

Editor: Update the ThemeJson unit test to cover custom CSS feature.

In #59499 a fix have been shipped to theme.json custom CSS
when applied to blocks with multiple CSS selectors.
This commit covers that fix with a unit test.

Props wildworks.
Fixes #60294.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/theme/wpThemeJson.php

    r57332 r57333  
    46894689    public function data_process_blocks_custom_css() {
    46904690        return array(
    4691             // Simple CSS without any child selectors.
    4692             'no child selectors'                => array(
     4691            // Simple CSS without any nested selectors.
     4692            'no nested selectors'          => array(
    46934693                'input'    => array(
    46944694                    'selector' => '.foo',
     
    46974697                'expected' => '.foo{color: red; margin: auto;}',
    46984698            ),
    4699             // CSS with child selectors.
    4700             'with children'                     => array(
     4699            // CSS with nested selectors.
     4700            'with nested selector'         => array(
    47014701                'input'    => array(
    47024702                    'selector' => '.foo',
    4703                     'css'      => 'color: red; margin: auto; & .bar{color: blue;}',
    4704                 ),
    4705                 'expected' => '.foo{color: red; margin: auto;}.foo .bar{color: blue;}',
    4706             ),
    4707             // CSS with child selectors and pseudo elements.
    4708             'with children and pseudo elements' => array(
     4703                    'css'      => 'color: red; margin: auto; &.one{color: blue;} & .two{color: green;}',
     4704                ),
     4705                'expected' => '.foo{color: red; margin: auto;}.foo.one{color: blue;}.foo .two{color: green;}',
     4706            ),
     4707            // CSS with pseudo elements.
     4708            'with pseudo elements'        => array(
    47094709                'input'    => array(
    47104710                    'selector' => '.foo',
    4711                     'css'      => 'color: red; margin: auto; & .bar{color: blue;} &::before{color: green;}',
    4712                 ),
    4713                 'expected' => '.foo{color: red; margin: auto;}.foo .bar{color: blue;}.foo::before{color: green;}',
     4711                    'css'      => 'color: red; margin: auto; &::before{color: blue;} & ::before{color: green;}  &.one::before{color: yellow;} & .two::before{color: purple;}',
     4712                ),
     4713                'expected' => '.foo{color: red; margin: auto;}.foo::before{color: blue;}.foo ::before{color: green;}.foo.one::before{color: yellow;}.foo .two::before{color: purple;}',
     4714            ),
     4715            // CSS with multiple root selectors.
     4716            'with multiple root selectors' => array(
     4717                'input'    => array(
     4718                    'selector' => '.foo, .bar',
     4719                    'css'      => 'color: red; margin: auto; &.one{color: blue;} & .two{color: green;} &::before{color: yellow;} & ::before{color: purple;}  &.three::before{color: orange;} & .four::before{color: skyblue;}',
     4720                ),
     4721                'expected' => '.foo, .bar{color: red; margin: auto;}.foo.one, .bar.one{color: blue;}.foo .two, .bar .two{color: green;}.foo::before, .bar::before{color: yellow;}.foo ::before, .bar ::before{color: purple;}.foo.three::before, .bar.three::before{color: orange;}.foo .four::before, .bar .four::before{color: skyblue;}',
    47144722            ),
    47154723        );
Note: See TracChangeset for help on using the changeset viewer.