Merge "Unit tests: Remove duplicated code in ExtensionRegistry"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 1 Sep 2019 19:56:12 +0000 (19:56 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 1 Sep 2019 19:56:12 +0000 (19:56 +0000)
includes/registration/ExtensionRegistry.php
tests/phpunit/bootstrap.php

index 3e65f6c..07fe318 100644 (file)
@@ -306,16 +306,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 );
 
index f227ae1..9e79496 100644 (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 );