Merge "mw.Upload.BookletLayout: Don't explode when the API call fails with 'exception'"
[lhc/web/wiklou.git] / tests / phpunit / phpunit.php
index aaa7751..0ae0b21 100755 (executable)
@@ -70,9 +70,12 @@ class PHPUnitMaintClass extends Maintenance {
                parent::finalSetup();
 
                global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgMainWANCache;
+               global $wgMainStash;
                global $wgLanguageConverterCacheType, $wgUseDatabaseMessages;
                global $wgLocaltimezone, $wgLocalisationCacheConf;
                global $wgDevelopmentWarnings;
+               global $wgSessionProviders;
+               global $wgJobTypeConf;
 
                // Inject test autoloader
                require_once __DIR__ . '/../TestsAutoLoader.php';
@@ -95,6 +98,10 @@ class PHPUnitMaintClass extends Maintenance {
                $wgLanguageConverterCacheType = 'hash';
                // Uses db-replicated in DefaultSettings
                $wgMainStash = 'hash';
+               // Use memory job queue
+               $wgJobTypeConf = array(
+                       'default' => array( 'class' => 'JobQueueMemory', 'order' => 'fifo' ),
+               );
 
                $wgUseDatabaseMessages = false; # Set for future resets
 
@@ -103,6 +110,19 @@ class PHPUnitMaintClass extends Maintenance {
 
                $wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
 
+               // Generic MediaWiki\Session\SessionManager configuration for tests
+               // We use CookieSessionProvider because things might be expecting
+               // cookies to show up in a FauxRequest somewhere.
+               $wgSessionProviders = array(
+                       array(
+                               'class' => 'MediaWiki\\Session\\CookieSessionProvider',
+                               'args' => array( array(
+                                       'priority' => 30,
+                                       'callUserSetCookiesHook' => true,
+                               ) ),
+                       ),
+               );
+
                // Bug 44192 Do not attempt to send a real e-mail
                Hooks::clear( 'AlternateUserMailer' );
                Hooks::register(
@@ -242,7 +262,6 @@ if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
        } );
 }
 
-
 $ok = false;
 
 if ( class_exists( 'PHPUnit_TextUI_Command' ) ) {
@@ -251,12 +270,19 @@ if ( class_exists( 'PHPUnit_TextUI_Command' ) ) {
 } else {
        foreach ( array(
                                stream_resolve_include_path( 'phpunit.phar' ),
+                               stream_resolve_include_path( 'phpunit-old.phar' ),
                                'PHPUnit/Runner/Version.php',
                                'PHPUnit/Autoload.php'
                        ) as $includePath ) {
-               // @codingStandardsIgnoreStart
-               @include_once $includePath;
-               // @codingStandardsIgnoreEnd
+
+               if ( $includePath === false ) {
+                       // stream_resolve_include_path can return false
+                       continue;
+               }
+
+               \MediaWiki\suppressWarnings();
+               include_once $includePath;
+               \MediaWiki\restoreWarnings();
                if ( class_exists( 'PHPUnit_TextUI_Command' ) ) {
                        $ok = true;
                        echo "Using PHPUnit from $includePath\n";