Unit tests: Remove duplicated code in ExtensionRegistry

Also use wgExtensionDirectory and wgStyleDirectory in bootstrap.php, and add
clarifying comment about why ExtensionRegistry->readFromQueue is not used.

Follows-Up: I237a9f82e4d1b05cf2f08b3e4bb7ffcd8d47111c

Bug: T226911
Change-Id: I9c8e70006600c6eebbdc46dc7483a4481859ea16
This commit is contained in:
Kosta Harlan 2019-08-19 10:16:06 +02:00
parent f32c4526b3
commit d66e16afb6
2 changed files with 7 additions and 14 deletions

View file

@ -307,16 +307,6 @@ class ExtensionRegistry {
$autoloadNamespaces
);
if ( isset( $info['AutoloadClasses'] ) ) {
$autoload = $this->processAutoLoader( $dir, $info['AutoloadClasses'] );
$GLOBALS['wgAutoloadClasses'] += $autoload;
$autoloadClasses += $autoload;
}
if ( isset( $info['AutoloadNamespaces'] ) ) {
$autoloadNamespaces += $this->processAutoLoader( $dir, $info['AutoloadNamespaces'] );
AutoLoader::$psr4Namespaces += $autoloadNamespaces;
}
// get all requirements/dependencies for this extension
$requires = $processor->getRequirements( $info, $this->checkDev );

View file

@ -74,16 +74,19 @@ 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.
// Populate classes and namespaces from extensions and skins present in filesystem.
$directoryToJsonMap = [
'extensions' => [ 'extension.json', 'extension-wip.json' ],
'skins' => [ 'skin.json', 'skin-wip.json' ]
$GLOBALS['wgExtensionDirectory'] => [ 'extension.json', 'extension-wip.json' ],
$GLOBALS['wgStyleDirectory'] => [ 'skin.json', 'skin-wip.json' ]
];
foreach ( $directoryToJsonMap as $directory => $jsonFile ) {
foreach ( new DirectoryIterator( __DIR__ . '/../../' . $directory ) as $iterator ) {
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 );