Skip to content

Commit 602018a

Browse files
Fix header tests to run in separate processes
Tests that flush output buffers call header() which fails when PHPUnit has already sent output. Adding @runInSeparateProcess prevents "headers already sent" errors.
1 parent c936dcc commit 602018a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/phpunit/tests/media/wpStartCrossOriginIsolationOutputBuffer.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public function tear_down() {
3737
parent::tear_down();
3838
}
3939

40+
/**
41+
* @runInSeparateProcess
42+
* @preserveGlobalState disabled
43+
*/
4044
public function test_starts_output_buffer_for_chrome_137() {
4145
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36';
4246

@@ -79,6 +83,10 @@ public function test_does_not_start_output_buffer_for_safari() {
7983
$this->assertSame( $level_before, $level_after, 'Output buffer should not be started for Safari.' );
8084
}
8185

86+
/**
87+
* @runInSeparateProcess
88+
* @preserveGlobalState disabled
89+
*/
8290
public function test_filter_can_force_enable_dip() {
8391
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 10.0; rv:128.0) Gecko/20100101 Firefox/128.0';
8492
add_filter( 'wp_use_document_isolation_policy', '__return_true' );
@@ -103,6 +111,10 @@ public function test_filter_can_force_disable_dip() {
103111
$this->assertSame( $level_before, $level_after, 'Filter should disable output buffer.' );
104112
}
105113

114+
/**
115+
* @runInSeparateProcess
116+
* @preserveGlobalState disabled
117+
*/
106118
public function test_output_buffer_adds_crossorigin_attributes() {
107119
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36';
108120

0 commit comments

Comments
 (0)