Otherwise, session tests don't work in PHP 7.2 because headers are
already sent: https://bugs.php.net/bug.php?id=75628
Bug: T206476
Change-Id: Ie88db4a61a56b756c6445d2579a2f30da22c3ee8
// Add our own listener
$this->arguments['listeners'][] = new MediaWikiPHPUnitTestListener;
+
+ // Output only to stderr to avoid "Headers already sent" problems
+ $this->arguments['stderr'] = true;
}
protected function createRunner() {
private function getResetter( &$rProp = null ) {
$reset = [];
- // Ignore "headers already sent" warnings during this test
- set_error_handler( function ( $errno, $errstr ) use ( &$warnings ) {
- if ( preg_match( '/[hH]eaders already sent/', $errstr ) ) {
- return true;
- }
- return false;
- } );
- $reset[] = new \Wikimedia\ScopedCallback( 'restore_error_handler' );
-
$rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' );
$rProp->setAccessible( true );
if ( $rProp->getValue() ) {
exit( 1 );
}
- echo defined( 'HHVM_VERSION' ) ?
+ fwrite( STDERR, defined( 'HHVM_VERSION' ) ?
'Using HHVM ' . HHVM_VERSION . ' (' . PHP_VERSION . ")\n" :
- 'Using PHP ' . PHP_VERSION . "\n";
+ 'Using PHP ' . PHP_VERSION . "\n" );
// Tell PHPUnit to ignore options meant for MediaWiki
$ignore = [];