From: Kosta Harlan Date: Mon, 19 Aug 2019 08:16:06 +0000 (+0200) Subject: Unit tests: Remove duplicated code in ExtensionRegistry X-Git-Tag: 1.34.0-rc.0~448^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations//%22%24printurl/%22?a=commitdiff_plain;h=d66e16afb69fb1b8efa98bc38d05044aa8703d0b;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 9cae73c907..b30d1d8358 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -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 ); diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php index f227ae1626..9e79496ac5 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/bootstrap.php @@ -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 );