$value ) { $GLOBALS[$varName] = $value; } } define( 'MEDIAWIKI', true ); define( 'MW_PHPUNIT_TEST', true ); $IP = realpath( __DIR__ . '/../../' ); // We don't use a settings file here but some code still assumes that one exists define( 'MW_CONFIG_FILE', "$IP/LocalSettings.php" ); // these variables must be defined before setup runs $GLOBALS['IP'] = $IP; require_once "$IP/tests/common/TestSetup.php"; TestSetup::snapshotGlobals(); // Faking in lieu of Setup.php $GLOBALS['wgScopeTest'] = 'MediaWiki Setup.php scope test'; $GLOBALS['wgCommandLineMode'] = true; $GLOBALS['wgAutoloadClasses'] = []; 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" ); // Populate classes and namespaces from extensions and skins present in filesystem. $directoryToJsonMap = [ $GLOBALS['wgExtensionDirectory'] => [ 'extension.json', 'extension-wip.json' ], $GLOBALS['wgStyleDirectory'] => [ 'skin.json', 'skin-wip.json' ] ]; foreach ( $directoryToJsonMap as $directory => $jsonFile ) { foreach ( new DirectoryIterator( $directory ) as $iterator ) { foreach ( $jsonFile as $file ) { $jsonPath = $iterator->getPathname() . '/' . $file; if ( file_exists( $jsonPath ) ) { // ExtensionRegistry->readFromQueue is not used as it checks extension/skin // dependencies, which we don't need or want for unit tests. $json = file_get_contents( $jsonPath ); $info = json_decode( $json, true ); $dir = dirname( $jsonPath ); ExtensionRegistry::exportAutoloadClassesAndNamespaces( $dir, $info ); } } } }