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.

git-svn-id: https://develop.svn.wordpress.org/trunk@50838 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2021-05-11 16:26:28 +00:00
parent 7f01308436
commit bab911f0d7
3 changed files with 48 additions and 51 deletions
+2
View File
@@ -259,6 +259,7 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
/**
* @ticket 50263
* @ticket 50328
*/
function test_success_register_block_style_handle() {
$metadata = array(
@@ -307,6 +308,7 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
* is found in the fixtures directory.
*
* @ticket 50263
* @ticket 50328
*/
function test_block_registers_with_metadata_fixture() {
$result = register_block_type_from_metadata(
+11 -17
View File
@@ -422,42 +422,36 @@ CSS;
}
/**
* Tests that the main "style.css" file gets enqueued when the site doesn't opt-in to separate_core_block_assets.
* Tests that the main "style.css" file gets enqueued when the site doesn't opt in to separate core block assets.
*
* @ticket 50263
*
* @covers ::wp_default_styles
*/
function test_common_block_styles_for_viewing_without_split_styles() {
function test_block_styles_for_viewing_without_split_styles() {
add_filter( 'separate_core_block_assets', '__return_false' );
wp_default_styles( $GLOBALS['wp_styles'] );
$this->assertSame(
$GLOBALS['wp_styles']->registered['wp-block-library']->src,
'/' . WPINC . '/css/dist/block-library/style.css'
'/' . WPINC . '/css/dist/block-library/style.css',
$GLOBALS['wp_styles']->registered['wp-block-library']->src
);
}
/**
* Tests that the "common.css" file gets enqueued when the site opts-in to separate_core_block_assets.
* Tests that the "common.css" file gets enqueued when the site opts in to separate core block assets.
*
* @ticket 50263
*
* @covers ::wp_default_styles
*/
function test_common_block_styles_for_viewing_with_split_styles() {
add_filter( 'separate_core_block_assets', '__return_false' );
wp_default_styles( $GLOBALS['wp_styles'] );
$this->assertSame(
$GLOBALS['wp_styles']->registered['wp-block-library']->src,
'/' . WPINC . '/css/dist/block-library/style.css'
);
}
function test_block_styles_for_viewing_with_split_styles() {
add_filter( 'separate_core_block_assets', '__return_true' );
wp_default_styles( $GLOBALS['wp_styles'] );
$this->assertSame(
$GLOBALS['wp_styles']->registered['wp-block-library']->src,
'/' . WPINC . '/css/dist/block-library/common.css'
'/' . WPINC . '/css/dist/block-library/common.css',
$GLOBALS['wp_styles']->registered['wp-block-library']->src
);
}
}