@@ -1393,35 +1393,39 @@ public function test_wp_load_classic_theme_block_styles_on_demand_in_block_theme
13931393 */
13941394 public function data_wp_load_classic_theme_block_styles_on_demand (): array {
13951395 return array (
1396- 'block_theme ' => array (
1396+ 'block_theme ' => array (
13971397 'theme ' => 'block-theme ' ,
13981398 'set_up ' => static function () {},
1399- 'expected_on_demand ' => false ,
1399+ 'expected_load_separate ' => true ,
1400+ 'expected_on_demand ' => true ,
14001401 'expected_buffer_started ' => false ,
14011402 ),
1402- 'classic_theme_with_output_buffer_blocked ' => array (
1403+ 'classic_theme_with_output_buffer_blocked ' => array (
14031404 'theme ' => 'default ' ,
14041405 'set_up ' => static function () {
14051406 add_filter ( 'wp_should_output_buffer_template_for_enhancement ' , '__return_false ' );
14061407 },
1408+ 'expected_load_separate ' => false ,
14071409 'expected_on_demand ' => false ,
14081410 'expected_buffer_started ' => false ,
14091411 ),
1410- 'classic_theme_with_block_styles_support ' => array (
1412+ 'classic_theme_with_should_load_separate_core_block_assets_opt_out ' => array (
14111413 'theme ' => 'default ' ,
14121414 'set_up ' => static function () {
1413- add_theme_support ( 'wp-block-styles ' );
1415+ add_filter ( 'should_load_separate_core_block_assets ' , ' __return_false ' );
14141416 },
1417+ 'expected_load_separate ' => false ,
14151418 'expected_on_demand ' => true ,
1416- 'expected_buffer_started ' => true ,
1419+ 'expected_buffer_started ' => false ,
14171420 ),
1418- 'classic_theme_without_block_styles_support ' => array (
1421+ 'classic_theme_with_should_load_block_assets_on_demand_out_out ' => array (
14191422 'theme ' => 'default ' ,
14201423 'set_up ' => static function () {
1421- remove_theme_support ( 'wp-block-styles ' );
1424+ add_filter ( 'should_load_block_assets_on_demand ' , ' __return_false ' );
14221425 },
1426+ 'expected_load_separate ' => true ,
14231427 'expected_on_demand ' => false ,
1424- 'expected_buffer_started ' => true ,
1428+ 'expected_buffer_started ' => false ,
14251429 ),
14261430 );
14271431 }
@@ -1436,7 +1440,7 @@ public function data_wp_load_classic_theme_block_styles_on_demand(): array {
14361440 *
14371441 * @dataProvider data_wp_load_classic_theme_block_styles_on_demand
14381442 */
1439- public function test_wp_load_classic_theme_block_styles_on_demand ( string $ theme , ?Closure $ set_up , bool $ expected_on_demand , bool $ expected_buffer_started ) {
1443+ public function test_wp_load_classic_theme_block_styles_on_demand ( string $ theme , ?Closure $ set_up , bool $ expected_load_separate , bool $ expected_on_demand , bool $ expected_buffer_started ) {
14401444 $ this ->assertFalse ( wp_should_load_separate_core_block_assets (), 'Expected wp_should_load_separate_core_block_assets() to return false initially. ' );
14411445 $ this ->assertFalse ( wp_should_load_block_assets_on_demand (), 'Expected wp_should_load_block_assets_on_demand() to return true ' );
14421446 $ this ->assertFalse ( has_action ( 'wp_template_enhancement_output_buffer_started ' , 'wp_hoist_late_printed_styles ' ), 'Expected wp_template_enhancement_output_buffer_started action to be added for classic themes. ' );
@@ -1447,8 +1451,9 @@ public function test_wp_load_classic_theme_block_styles_on_demand( string $theme
14471451 }
14481452
14491453 wp_load_classic_theme_block_styles_on_demand ();
1454+ _add_default_theme_supports ();
14501455
1451- $ this ->assertSame ( $ expected_on_demand , wp_should_load_separate_core_block_assets (), 'Expected wp_should_load_separate_core_block_assets() return value. ' );
1456+ $ this ->assertSame ( $ expected_load_separate , wp_should_load_separate_core_block_assets (), 'Expected wp_should_load_separate_core_block_assets() return value. ' );
14521457 $ this ->assertSame ( $ expected_on_demand , wp_should_load_block_assets_on_demand (), 'Expected wp_should_load_block_assets_on_demand() return value. ' );
14531458 $ this ->assertSame ( $ expected_buffer_started , (bool ) has_action ( 'wp_template_enhancement_output_buffer_started ' , 'wp_hoist_late_printed_styles ' ), 'Expected wp_template_enhancement_output_buffer_started action added status. ' );
14541459 }
0 commit comments