Make WordPress Core

Changeset 51054


Ignore:
Timestamp:
06/01/2021 11:30:05 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Remove the ::append_to_selector() method from Tests_Theme_wpThemeJson.

The method exists in the WP_Theme_JSON class and appears to be erroneously duplicated in the test class.

Add a unit test that was meant to be included instead, as per https://github.com/WordPress/gutenberg/pull/32190.

Follow-up to [51051].

See #52991.

File:
1 edited

Legend:

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

    r51051 r51054  
    168168            'body{--wp--preset--color--grey: grey;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}',
    169169            $theme_json->get_stylesheet( 'css_variables' )
     170        );
     171    }
     172
     173    function test_get_stylesheet_preset_classes_work_with_compounded_selectors() {
     174        $theme_json = new WP_Theme_JSON(
     175            array(
     176                'version'  => WP_Theme_JSON::LATEST_SCHEMA,
     177                'settings' => array(
     178                    'blocks' => array(
     179                        'core/heading' => array(
     180                            'color' => array(
     181                                'palette' => array(
     182                                    array(
     183                                        'slug'  => 'white',
     184                                        'color' => '#fff',
     185                                    ),
     186                                ),
     187                            ),
     188                        ),
     189                    ),
     190                ),
     191            )
     192        );
     193
     194        $this->assertEquals(
     195            'h1.has-white-color,h2.has-white-color,h3.has-white-color,h4.has-white-color,h5.has-white-color,h6.has-white-color{color: #fff !important;}h1.has-white-background-color,h2.has-white-background-color,h3.has-white-background-color,h4.has-white-background-color,h5.has-white-background-color,h6.has-white-background-color{background-color: #fff !important;}',
     196            $theme_json->get_stylesheet( 'block_styles' )
    170197        );
    171198    }
     
    621648
    622649    /**
    623      * Function that appends a sub-selector to a existing one.
    624      *
    625      * Given the compounded $selector "h1, h2, h3"
    626      * and the $to_append selector ".some-class" the result will be
    627      * "h1.some-class, h2.some-class, h3.some-class".
    628      *
    629      * @param string $selector Original selector.
    630      * @param string $to_append Selector to append.
    631      *
    632      * @return string
    633      */
    634     private static function append_to_selector( $selector, $to_append ) {
    635         $new_selectors = array();
    636         $selectors     = explode( ',', $selector );
    637         foreach ( $selectors as $sel ) {
    638             $new_selectors[] = $sel . $to_append;
    639         }
    640 
    641         return implode( ',', $new_selectors );
    642     }
    643 
    644     /**
    645650     * @ticket 52991
    646651     */
Note: See TracChangeset for help on using the changeset viewer.