Output only to stderr in unit tests
authorAryeh Gregor <ayg@aryeh.name>
Mon, 8 Oct 2018 18:04:12 +0000 (21:04 +0300)
committerKunal Mehta <legoktm@member.fsf.org>
Tue, 16 Oct 2018 00:50:26 +0000 (17:50 -0700)
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
tests/phpunit/phpunit.php
tests/phpunit/suite.xml

index 0135bb9..045ba2f 100644 (file)
@@ -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() ) {
index 7cf042d..650cfcf 100755 (executable)
@@ -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() );
index e8256ef..16c0c17 100644 (file)
@@ -16,6 +16,7 @@
        beStrictAboutTestsThatDoNotTestAnything="true"
        beStrictAboutOutputDuringTests="true"
        beStrictAboutTestSize="true"
+       stderr="true"
        verbose="false">
        <testsuites>
                <testsuite name="includes">