Add tests for Job::toString
[lhc/web/wiklou.git] / tests / phpunit / phpunit.php
index 7dd932f..1125504 100755 (executable)
@@ -148,17 +148,17 @@ class PHPUnitMaintClass extends Maintenance {
                }
 
                $key = array_search( '--debug-tests', $_SERVER['argv'] );
-               if( $key !== false && array_search( '--printer', $_SERVER['argv'] ) === false ) {
+               if ( $key !== false && array_search( '--printer', $_SERVER['argv'] ) === false ) {
                        unset( $_SERVER['argv'][$key] );
                        array_splice( $_SERVER['argv'], 1, 0, 'MediaWikiPHPUnitTestListener' );
                        array_splice( $_SERVER['argv'], 1, 0, '--printer' );
                }
 
-               foreach( self::$additionalOptions as $option => $default ) {
+               foreach ( self::$additionalOptions as $option => $default ) {
                        $key = array_search( '--' . $option, $_SERVER['argv'] );
-                       if( $key !== false ) {
+                       if ( $key !== false ) {
                                unset( $_SERVER['argv'][$key] );
-                               if( $this->mParams[$option]['withArg'] ) {
+                               if ( $this->mParams[$option]['withArg'] ) {
                                        self::$additionalOptions[$option] = $_SERVER['argv'][$key + 1];
                                        unset( $_SERVER['argv'][$key + 1] );
                                } else {
@@ -179,11 +179,11 @@ class PHPUnitMaintClass extends Maintenance {
         */
        private function forceFormatServerArgv() {
                $argv = array();
-               foreach( $_SERVER['argv'] as $key => $arg ) {
-                       if( $key === 0 ) {
+               foreach ( $_SERVER['argv'] as $key => $arg ) {
+                       if ( $key === 0 ) {
                                $argv[0] = $arg;
                        } elseif ( strstr( $arg, '=' ) ) {
-                               foreach( explode( '=', $arg, 2 ) as $argPart ) {
+                               foreach ( explode( '=', $arg, 2 ) as $argPart ) {
                                        $argv[] = $argPart;
                                }
                        } else {
@@ -198,36 +198,36 @@ class PHPUnitMaintClass extends Maintenance {
 $maintClass = 'PHPUnitMaintClass';
 require RUN_MAINTENANCE_IF_MAIN;
 
-$pharFile = stream_resolve_include_path( 'phpunit.phar' );
-$isValidPhar = Phar::isValidPharFilename( $pharFile );
-
-if ( !$isValidPhar && !class_exists( 'PHPUnit_Runner_Version' ) ) {
-       // try loading phpunit via PEAR
-       require_once 'PHPUnit/Runner/Version.php';
-}
-
 // Prevent segfault when we have lots of unit tests (bug 62623)
-if ( version_compare( PHP_VERSION, '5.4.0', '<' )
-       && version_compare( PHP_VERSION, '5.3.0', '>=' )
-) {
+if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
        register_shutdown_function( function () {
                gc_collect_cycles();
                gc_disable();
        } );
 }
 
-if ( $isValidPhar ) {
-       require $pharFile;
-} else {
-       if ( PHPUnit_Runner_Version::id() !== '@package_version@'
-           && version_compare( PHPUnit_Runner_Version::id(), '3.7.0', '<' )
-       ) {
-           die( 'PHPUnit 3.7.0 or later required, you have ' . PHPUnit_Runner_Version::id() . ".\n" );
-       }
 
-       if ( !class_exists( 'PHPUnit_TextUI_Command' ) ) {
-           require_once 'PHPUnit/Autoload.php';
+$ok = false;
+
+foreach ( array(
+       stream_resolve_include_path( 'phpunit.phar' ),
+       'PHPUnit/Runner/Version.php',
+       'PHPUnit/Autoload.php'
+) as $includePath ) {
+       @include_once $includePath;
+       if ( class_exists( 'PHPUnit_TextUI_Command' ) ) {
+               $ok = true;
+               break;
        }
+}
+
+if ( !$ok ) {
+       die( "Couldn't find a usable PHPUnit.\n" );
+}
 
-       PHPUnit_TextUI_Command::main();
+$puVersion = PHPUnit_Runner_Version::id();
+if ( $puVersion !== '@package_version@' && version_compare( $puVersion, '3.7.0', '<' ) ) {
+       die( "PHPUnit 3.7.0 or later required; you have {$puVersion}.\n" );
 }
+
+PHPUnit_TextUI_Command::main();