Skip to content

Commit 65a9250

Browse files
committed
Add assertions for when footer script printing actions are removed
1 parent e7cec6b commit 65a9250

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

tests/phpunit/tests/template.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,13 +946,48 @@ public function test_wp_load_classic_theme_block_styles_on_demand_in_classic_the
946946
$this->assertNotFalse( 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.' );
947947
}
948948

949+
/**
950+
* Data provider.
951+
*
952+
* @return array<string, array{set_up?: Closure}>
953+
*/
954+
public function data_provider_for_test_wp_hoist_late_printed_styles(): array {
955+
return array(
956+
'no_actions_removed' => array(
957+
'set_up' => null,
958+
),
959+
'_wp_footer_scripts_removed' => array(
960+
'set_up' => static function () {
961+
remove_action( 'wp_print_footer_scripts', '_wp_footer_scripts' );
962+
},
963+
),
964+
'wp_print_footer_scripts_removed' => array(
965+
'set_up' => static function () {
966+
remove_action( 'wp_footer', 'wp_print_footer_scripts', 20 );
967+
},
968+
),
969+
'both_actions_removed' => array(
970+
'set_up' => static function () {
971+
remove_action( 'wp_print_footer_scripts', '_wp_footer_scripts' );
972+
remove_action( 'wp_footer', 'wp_print_footer_scripts' );
973+
},
974+
),
975+
);
976+
}
977+
949978
/**
950979
* Tests that wp_hoist_late_printed_styles() adds a placeholder for delayed CSS, then removes it and adds all CSS to the head including late enqueued styles.
951980
*
952981
* @ticket 64099
953982
* @covers ::wp_hoist_late_printed_styles
983+
*
984+
* @dataProvider data_provider_for_test_wp_hoist_late_printed_styles
954985
*/
955-
public function test_wp_hoist_late_printed_styles(): void {
986+
public function test_wp_hoist_late_printed_styles( ?Closure $set_up ): void {
987+
if ( $set_up ) {
988+
$set_up();
989+
}
990+
956991
switch_theme( 'default' );
957992

958993
// Enqueue a style

0 commit comments

Comments
 (0)