Skip to content

Commit 80d18e8

Browse files
committed
add test for wp_always_load_block_styles_on_demand_init
1 parent f0e4735 commit 80d18e8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/phpunit/tests/template.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,27 @@ public function test_wp_start_template_enhancement_output_buffer_for_json(): voi
830830
$this->assertSame( $json, $output, 'Expected output to not be processed.' );
831831
}
832832

833+
// public function test_wp_always_load_block_styles_on_demand_init_in_block_theme(): void {
834+
// // If we're in a block theme, expect no filters to be added.
835+
836+
// }
837+
838+
/**
839+
* Tests that wp_always_load_block_styles_on_demand adds the expected filters for classic themes.
840+
*
841+
* @ticket 64099
842+
* @covers ::wp_always_load_block_styles_on_demand_init
843+
*/
844+
public function test_wp_always_load_block_styles_on_demand_init_in_classic_theme(): void {
845+
// If we're in a classic theme, expect filters to be added.
846+
$default = null;
847+
$this->assertTrue( has_filter( 'should_load_separate_core_block_assets' ), 'Expect should_load_separate_core_block_assets filter to be added for classic themes.' );
848+
$this->assertTrue( apply_filters( 'should_load_separate_core_block_assets', $default ), 'Expect should_load_separate_core_block_assets filters to return true' );
849+
$this->assertTrue( has_filter( 'should_load_block_assets_on_demand' ), 'Expect should_load_block_assets_on_demand filter to be added for classic themes.' );
850+
$this->assertTrue( apply_filters( 'should_load_block_assets_on_demand', $default ), 'Expect should_load_separate_core_block_assets filters to return true' );
851+
$this->assertTrue( true == has_action( 'wp_template_enhancement_output_buffer_started', 'wp_use_placeholder_for_delayed_css' ), 'Expect wp_template_enhancement_output_buffer_started filter to be added for classic themes.' );
852+
}
853+
833854
public function assertTemplateHierarchy( $url, array $expected, $message = '' ) {
834855
$this->go_to( $url );
835856
$hierarchy = $this->get_template_hierarchy();

0 commit comments

Comments
 (0)