From 7a547df7c08e0236ba09376cf786de747a4eb19c Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Mon, 8 Oct 2018 21:04:12 +0300 Subject: [PATCH] Output only to stderr in unit tests 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 --- tests/phpunit/includes/session/PHPSessionHandlerTest.php | 9 --------- tests/phpunit/phpunit.php | 4 ++-- tests/phpunit/suite.xml | 1 + 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/includes/session/PHPSessionHandlerTest.php b/tests/phpunit/includes/session/PHPSessionHandlerTest.php index 0135bb91e1..045ba2f08c 100644 --- a/tests/phpunit/includes/session/PHPSessionHandlerTest.php +++ b/tests/phpunit/includes/session/PHPSessionHandlerTest.php @@ -15,15 +15,6 @@ class PHPSessionHandlerTest extends MediaWikiTestCase { 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() ) { diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php index 7cf042d0b8..650cfcfa3a 100755 --- a/tests/phpunit/phpunit.php +++ b/tests/phpunit/phpunit.php @@ -124,9 +124,9 @@ class PHPUnitMaintClass extends Maintenance { 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" ); // Prepare global services for unit tests. MediaWikiTestCase::prepareServices( new GlobalVarConfig() ); diff --git a/tests/phpunit/suite.xml b/tests/phpunit/suite.xml index e8256ef2cb..16c0c17cdc 100644 --- a/tests/phpunit/suite.xml +++ b/tests/phpunit/suite.xml @@ -16,6 +16,7 @@ beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" beStrictAboutTestSize="true" + stderr="true" verbose="false"> -- 2.20.1