$value ) { $GLOBALS[$var] = $value; } TestSetup::requireOnceInGlobalScope( MW_INSTALL_PATH . "/includes/DevelopmentSettings.php" ); TestSetup::applyInitialConfig(); // Shell out to another script that will give us a list of loaded extensions and skins. We need to do that in another // process, not in this one, because loading setting files may have non-trivial side effects that could be hard // to undo. This sucks, but there doesn't seem to be a way to get a list of extensions and skins without loading // all of MediaWiki, which we don't want to do for unit tests. // phpcs:ignore MediaWiki.Usage.ForbiddenFunctions.proc_open $process = proc_open( __DIR__ . '/getPHPUnitExtensionsAndSkins.php', [ 0 => [ 'pipe', 'r' ], 1 => [ 'pipe', 'w' ], 2 => [ 'pipe', 'w' ] ], $pipes ); $extensionData = stream_get_contents( $pipes[1] ); fclose( $pipes[1] ); $cmdErr = stream_get_contents( $pipes[2] ); fclose( $pipes[2] ); $exitCode = proc_close( $process ); if ( $exitCode !== 0 ) { echo "Cannot load list of extensions and skins. Output:\n$cmdErr\n"; exit( 1 ); } // For simplicity, getPHPUnitExtensionsAndSkins uses `\n\nTESTPATHS\n\n` to separate the lists of JSON files and // additional test paths, so split the output into the individual lists. [ $pathsToJsonFilesStr, $testPathsStr ] = explode( "\n\nTESTPATHS\n\n", $extensionData ); $pathsToJsonFiles = explode( "\n", $pathsToJsonFilesStr ); /** @internal For use in ExtensionsUnitTestSuite and SkinsUnitTestSuite only */ define( 'MW_PHPUNIT_EXTENSIONS_PATHS', array_map( 'dirname', $pathsToJsonFiles ) ); /** @internal For use in ExtensionsTestSuite only */ define( 'MW_PHPUNIT_EXTENSIONS_TEST_PATHS', explode( "\n", $testPathsStr ) ); $extensionProcessor = new ExtensionProcessor(); foreach ( $pathsToJsonFiles as $filePath ) { $extensionProcessor->extractInfoFromFile( $filePath ); } $autoload = $extensionProcessor->getExtractedAutoloadInfo( true ); AutoLoader::loadFiles( $autoload['files'] ); AutoLoader::registerClasses( $autoload['classes'] ); AutoLoader::registerNamespaces( $autoload['namespaces'] ); // More faking in lieu of Setup.php Profiler::init( [] ); TestSetup::maybeCheckComposerLockUpToDate();