Call ob_start() before running tests
authorTim Starling <tstarling@wikimedia.org>
Mon, 25 May 2020 03:48:42 +0000 (13:48 +1000)
committersbassett <sbassett@wikimedia.org>
Mon, 1 Jun 2020 19:28:40 +0000 (14:28 -0500)
The policy introduced for T206476 creates a subtle failure mode: any test
writing to stdout will cause headers to be sent, causing later tests to
fail when they try to call header().

Instead, call ob_start() to intercept test output. Any buffered output is
still seen when PHPUnit exits.

Bug: T206476
Change-Id: Id085efeab67d1e700ffcbf37868b5107e3a7e5d5

tests/phpunit/phpunit.php

index 650cfcf..6036e3f 100755 (executable)
@@ -124,6 +124,10 @@ class PHPUnitMaintClass extends Maintenance {
                        exit( 1 );
                }
 
+               // Start an output buffer to avoid headers being sent by constructors,
+               // data providers, etc. (T206476)
+               ob_start();
+
                fwrite( STDERR, defined( 'HHVM_VERSION' ) ?
                        'Using HHVM ' . HHVM_VERSION . ' (' . PHP_VERSION . ")\n" :
                        'Using PHP ' . PHP_VERSION . "\n" );