Merge "Exclude redirects from Special:Fewestrevisions"
[lhc/web/wiklou.git] / tests / phpunit / bootstrap.php
index 258c822..4400475 100644 (file)
@@ -56,6 +56,12 @@ $IP = realpath( __DIR__ . '/../../' );
 
 // these variables must be defined before setup runs
 $GLOBALS['IP'] = $IP;
+// Set bootstrap globals to reuse in MediaWikiUnitTestCase
+$bootstrapGlobals = [];
+foreach ( $GLOBALS as $key => $value ) {
+       $bootstrapGlobals[ $key ] = $value;
+}
+$GLOBALS['wgPhpUnitBootstrapGlobals'] = $bootstrapGlobals;
 // Faking for Setup.php
 $GLOBALS['wgScopeTest'] = 'MediaWiki Setup.php scope test';
 $GLOBALS['wgCommandLineMode'] = true;
@@ -65,3 +71,25 @@ require_once "$IP/tests/common/TestSetup.php";
 
 wfRequireOnceInGlobalScope( "$IP/includes/AutoLoader.php" );
 wfRequireOnceInGlobalScope( "$IP/tests/common/TestsAutoLoader.php" );
+wfRequireOnceInGlobalScope( "$IP/includes/Defines.php" );
+wfRequireOnceInGlobalScope( "$IP/includes/DefaultSettings.php" );
+wfRequireOnceInGlobalScope( "$IP/includes/GlobalFunctions.php" );
+
+// Load extensions/skins present in filesystem so that classes can be discovered.
+$directoryToJsonMap = [
+       'extensions' => [ 'extension.json', 'extension-wip.json' ],
+       'skins' => [ 'skin.json', 'skin-wip.json' ]
+];
+foreach ( $directoryToJsonMap as $directory => $jsonFile ) {
+       foreach ( new DirectoryIterator( __DIR__ . '/../../' . $directory ) as $iterator ) {
+               foreach ( $jsonFile as $file ) {
+                       $jsonPath = $iterator->getPathname() . '/' . $file;
+                       if ( file_exists( $jsonPath ) ) {
+                               $json = file_get_contents( $jsonPath );
+                               $info = json_decode( $json, true );
+                               $dir = dirname( $jsonPath );
+                               ExtensionRegistry::exportAutoloadClassesAndNamespaces( $dir, $info );
+                       }
+               }
+       }
+}