}
$dir = dirname( $path );
+ self::exportAutoloadClassesAndNamespaces(
+ $dir,
+ $info,
+ $autoloadClasses,
+ $autoloadNamespaces
+ );
+
if ( isset( $info['AutoloadClasses'] ) ) {
$autoload = $this->processAutoLoader( $dir, $info['AutoloadClasses'] );
$GLOBALS['wgAutoloadClasses'] += $autoload;
return $data;
}
+ /**
+ * Export autoload classes and namespaces for a given directory and parsed JSON info file.
+ *
+ * @param string $dir
+ * @param array $info
+ * @param array &$autoloadClasses
+ * @param array &$autoloadNamespaces
+ */
+ public static function exportAutoloadClassesAndNamespaces(
+ $dir, $info, &$autoloadClasses = [], &$autoloadNamespaces = []
+ ) {
+ if ( isset( $info['AutoloadClasses'] ) ) {
+ $autoload = self::processAutoLoader( $dir, $info['AutoloadClasses'] );
+ $GLOBALS['wgAutoloadClasses'] += $autoload;
+ $autoloadClasses += $autoload;
+ }
+ if ( isset( $info['AutoloadNamespaces'] ) ) {
+ $autoloadNamespaces += self::processAutoLoader( $dir, $info['AutoloadNamespaces'] );
+ AutoLoader::$psr4Namespaces += $autoloadNamespaces;
+ }
+ }
+
protected function exportExtractedData( array $info ) {
foreach ( $info['globals'] as $key => $val ) {
// If a merge strategy is set, read it and remove it from the value
* @param array $files
* @return array
*/
- protected function processAutoLoader( $dir, array $files ) {
+ protected static function processAutoLoader( $dir, array $files ) {
// Make paths absolute, relative to the JSON file
foreach ( $files as &$file ) {
$file = "$dir/$file";
<testsuites>
<testsuite name="unit">
<directory>tests/phpunit/unit</directory>
+ <directory>**/**/tests/phpunit/unit</directory>
</testsuite>
<testsuite name="integration">
<directory>tests/phpunit/integration</directory>
+ <directory>**/**/tests/phpunit/integration</directory>
</testsuite>
</testsuites>
<groups>
wfRequireOnceInGlobalScope( "$IP/includes/AutoLoader.php" );
wfRequireOnceInGlobalScope( "$IP/tests/common/TestsAutoLoader.php" );
wfRequireOnceInGlobalScope( "$IP/includes/Defines.php" );
+wfRequireOnceInGlobalScope( "$IP/includes/DefaultSettings.php" );
+
+// Load extensions/skins present in filesystem so that classes can be discovered.
+$directoryToJsonMap = [
+ 'extensions' => [ 'extension.json', 'extension-wip.json' ],
+ 'skins' => [ 'skin.json', 'skin-wip.json' ]
+];
+foreach ( $directoryToJsonMap as $directory => $jsonFile ) {
+ foreach ( new DirectoryIterator( __DIR__ . '/../../' . $directory ) as $iterator ) {
+ foreach ( $jsonFile as $file ) {
+ $jsonPath = $iterator->getPathname() . '/' . $file;
+ if ( file_exists( $jsonPath ) ) {
+ $json = file_get_contents( $jsonPath );
+ $info = json_decode( $json, true );
+ $dir = dirname( $jsonPath );
+ ExtensionRegistry::exportAutoloadClassesAndNamespaces( $dir, $info );
+ }
+ }
+ }
+}