Make WordPress Core


Ignore:
Timestamp:
09/19/2022 08:54:20 PM (4 years ago)
Author:
audrasjb
Message:

Editor: Backport block supports filter callback, registrations and tests to 6.1.

This changeset backports the following changes:

Props ramonopoly, gziolo, bernhard-reiter, audrasjb, costdev.
See #56467.

File:
1 edited

Legend:

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

    r53916 r54214  
    5555        }
    5656
     57        /**
     58         * Cleans up global scope.
     59         *
     60         * @global WP_Styles $wp_styles
     61         */
     62        public function clean_up_global_scope() {
     63                global $wp_styles;
     64                parent::clean_up_global_scope();
     65                $wp_styles = null;
     66        }
     67
    5768        public function filter_set_theme_root() {
    5869                return $this->theme_root;
    … …  
    200211        }
    201212
     213        /**
     214         * Tests that stored CSS is enqueued.
     215         *
     216         * @ticket 56467
     217         *
     218         * @covers ::wp_enqueue_stored_styles
     219         */
     220        public function test_should_enqueue_stored_styles() {
     221                $core_styles_to_enqueue = array(
     222                        array(
     223                                'selector'     => '.saruman',
     224                                'declarations' => array(
     225                                        'color'        => 'white',
     226                                        'height'       => '100px',
     227                                        'border-style' => 'solid',
     228                                ),
     229                        ),
     230                );
     231
     232                // Enqueues a block supports (core styles).
     233                wp_style_engine_get_stylesheet_from_css_rules(
     234                        $core_styles_to_enqueue,
     235                        array(
     236                                'context' => 'block-supports',
     237                        )
     238                );
     239
     240                $my_styles_to_enqueue = array(
     241                        array(
     242                                'selector'     => '.gandalf',
     243                                'declarations' => array(
     244                                        'color'        => 'grey',
     245                                        'height'       => '90px',
     246                                        'border-style' => 'dotted',
     247                                ),
     248                        ),
     249                );
     250
     251                // Enqueues some other styles.
     252                wp_style_engine_get_stylesheet_from_css_rules(
     253                        $my_styles_to_enqueue,
     254                        array(
     255                                'context' => 'my-styles',
     256                        )
     257                );
     258
     259                wp_enqueue_stored_styles( array( 'prettify' => false ) );
     260
     261                $this->assertSame(
     262                        array( '.saruman{color:white;height:100px;border-style:solid;}' ),
     263                        wp_styles()->registered['core-block-supports']->extra['after'],
     264                        'Registered styles with handle of "core-block-supports" do not match expected value from Style Engine store.'
     265                );
     266
     267                $this->assertSame(
     268                        array( '.gandalf{color:grey;height:90px;border-style:dotted;}' ),
     269                        wp_styles()->registered['wp-style-engine-my-styles']->extra['after'],
     270                        'Registered styles with handle of "wp-style-engine-my-styles" do not match expected value from the Style Engine store.'
     271                );
     272        }
    202273}
Note: See TracChangeset for help on using the changeset viewer.