@@ -127,8 +127,6 @@ public function set_up() {
127127 $ this ->original_wp_styles = $ wp_styles ;
128128 $ wp_scripts = null ;
129129 $ wp_styles = null ;
130- wp_scripts ();
131- wp_styles ();
132130
133131 foreach ( self ::RESTORED_CONFIG_OPTIONS as $ option ) {
134132 $ this ->original_ini_config [ $ option ] = ini_get ( $ option );
@@ -1647,6 +1645,9 @@ function (): void {
16471645 * @dataProvider data_wp_hoist_late_printed_styles
16481646 */
16491647 public function test_wp_hoist_late_printed_styles ( ?Closure $ set_up , int $ inline_size_limit , array $ expected_styles ): void {
1648+ $ GLOBALS ['debug_on_demand_block_style ' ] = true ; // TODO: Remove.
1649+ error_log ( "\n##BEGIN DEBUG #################################### \n" );
1650+
16501651 switch_theme ( 'default ' );
16511652 global $ wp_styles ;
16521653 $ wp_styles = null ;
@@ -1674,8 +1675,26 @@ static function () {
16741675
16751676 // Ensure that separate core block assets get registered.
16761677 register_core_block_style_handles ();
1678+ $ this ->assertTrue ( WP_Block_Type_Registry::get_instance ()->is_registered ( 'core/separator ' ), 'Expected the core/separator block to be registered. ' );
16771679 if ( wp_should_load_separate_core_block_assets () ) {
1678- $ this ->assertTrue ( wp_style_is ( 'wp-block-separator ' , 'registered ' ), 'Expected the wp-block-separator style to be registered. ' );
1680+ $ handle = 'wp-block-separator ' ;
1681+ $ this ->assertTrue ( wp_style_is ( $ handle , 'registered ' ), 'Expected the wp-block-separator style to be registered. ' );
1682+ $ dependency = wp_styles ()->query ( $ handle );
1683+ error_log ( __FILE__ . ': ' . __LINE__ . ' $dependency->src === ' . $ dependency ->src );
1684+ $ dependency ->src = includes_url ( 'wp-includes/blocks/separator/style.css ' );
1685+
1686+ $ path = ABSPATH . WPINC . '/blocks/separator/style.css ' ;
1687+ if ( ! file_exists ( $ path ) ) {
1688+ error_log ( __FILE__ . ': ' . __LINE__ . ' FILE DOES NOT EXIST: ' . $ path );
1689+ file_put_contents ( $ path , '/* The separator CSS */ ' );
1690+ } else {
1691+ error_log ( __FILE__ . ': ' . __LINE__ . ' FILE DOES EXIST: ' . $ path );
1692+ }
1693+ wp_style_add_data ( $ handle , 'path ' , $ path );
1694+
1695+ $ done = wp_styles ()->done ;
1696+ error_log ( __FILE__ . ': ' . __LINE__ . ": wp_print_styles( $ handle): " . get_echo ( 'wp_print_styles ' , array ( $ handle ) ) );
1697+ wp_styles ()->done = $ done ;
16791698 }
16801699
16811700 $ this ->assertFalse ( wp_is_block_theme (), 'Test is not relevant to block themes (only classic themes). ' );
@@ -1712,6 +1731,9 @@ static function () {
17121731 'the_content ' ,
17131732 '<!-- wp:separator --><hr class="wp-block-separator has-alpha-channel-opacity"/><!-- /wp:separator --> '
17141733 );
1734+ if ( ! empty ( $ GLOBALS ['debug_on_demand_block_style ' ] ) ) {
1735+ error_log ( __FILE__ . ': ' . __LINE__ . ' wp_styles()->queue: ' . json_encode ( wp_styles ()->queue ) );
1736+ }
17151737
17161738 // Simulate footer scripts.
17171739 $ footer_output = get_echo ( 'wp_footer ' );
@@ -1757,6 +1779,9 @@ static function () {
17571779 $ found_subset_styles ,
17581780 'Expected the same styles. Snapshot: ' . self ::get_array_snapshot_export ( $ found_styles )
17591781 );
1782+
1783+ unset( $ GLOBALS ['debug_on_demand_block_style ' ] ); // TODO: Remove.
1784+ error_log ( "\n##END DEBUG #################################### \n" ); // TODO: Remove.
17601785 }
17611786
17621787 public function assertTemplateHierarchy ( $ url , array $ expected , $ message = '' ) {
0 commit comments