WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/11/2021 04:26:28 PM (6 months ago)
Author:
SergeyBiryukov
Message:

Editor: Some documentation and test improvements for loading separate assets for core blocks:

  • Move should_load_separate_core_block_assets() to a more appropriate place.
  • Update DocBlocks and inline comments per the documentation standards.
  • Document the $wp_styles global in wp_maybe_inline_styles().
  • List the expected result first in unit test assertions.
  • Remove a duplicate unit test.
  • Add missing @covers tags.

Follow-up to [50836], [50837].

See #50328, #52620, #53180.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/dependencies/styles.php

    r50836 r50838  
    423423
    424424    /**
    425      * Tests that the main "style.css" file gets enqueued when the site doesn't opt-in to separate_core_block_assets.
     425     * Tests that the main "style.css" file gets enqueued when the site doesn't opt in to separate core block assets.
    426426     *
    427427     * @ticket 50263
    428      */
    429     function test_common_block_styles_for_viewing_without_split_styles() {
     428     *
     429     * @covers ::wp_default_styles
     430     */
     431    function test_block_styles_for_viewing_without_split_styles() {
    430432        add_filter( 'separate_core_block_assets', '__return_false' );
    431433        wp_default_styles( $GLOBALS['wp_styles'] );
    432434
    433435        $this->assertSame(
    434             $GLOBALS['wp_styles']->registered['wp-block-library']->src,
    435             '/' . WPINC . '/css/dist/block-library/style.css'
     436            '/' . WPINC . '/css/dist/block-library/style.css',
     437            $GLOBALS['wp_styles']->registered['wp-block-library']->src
    436438        );
    437439    }
    438440
    439441    /**
    440      * Tests that the "common.css" file gets enqueued when the site opts-in to separate_core_block_assets.
     442     * Tests that the "common.css" file gets enqueued when the site opts in to separate core block assets.
    441443     *
    442444     * @ticket 50263
    443      */
    444     function test_common_block_styles_for_viewing_with_split_styles() {
    445         add_filter( 'separate_core_block_assets', '__return_false' );
    446         wp_default_styles( $GLOBALS['wp_styles'] );
    447 
    448         $this->assertSame(
    449             $GLOBALS['wp_styles']->registered['wp-block-library']->src,
    450             '/' . WPINC . '/css/dist/block-library/style.css'
    451         );
    452     }
    453 
     445     *
     446     * @covers ::wp_default_styles
     447     */
    454448    function test_block_styles_for_viewing_with_split_styles() {
    455449        add_filter( 'separate_core_block_assets', '__return_true' );
     
    457451
    458452        $this->assertSame(
    459             $GLOBALS['wp_styles']->registered['wp-block-library']->src,
    460             '/' . WPINC . '/css/dist/block-library/common.css'
     453            '/' . WPINC . '/css/dist/block-library/common.css',
     454            $GLOBALS['wp_styles']->registered['wp-block-library']->src
    461455        );
    462456    }
Note: See TracChangeset for help on using the changeset viewer.