Merge "registration: Fix handling of MessagesDirs array and add tests"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 3 Feb 2015 00:26:33 +0000 (00:26 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 3 Feb 2015 00:26:33 +0000 (00:26 +0000)
includes/registration/ExtensionProcessor.php
tests/phpunit/includes/registration/ExtensionProcessorTest.php

index 25222f6..8a6530b 100644 (file)
@@ -204,9 +204,11 @@ class ExtensionProcessor implements Processor {
        protected function extractMessageSettings( $dir, array $info ) {
                foreach ( array( 'ExtensionMessagesFiles', 'MessagesDirs' ) as $key ) {
                        if ( isset( $info[$key] ) ) {
-                               $this->globals["wg$key"] += array_map( function( $file ) use ( $dir ) {
-                                       return "$dir/$file";
-                               }, $info[$key] );
+                               foreach ( $info[$key] as $name => $files ) {
+                                       foreach ( (array)$files as $file ) {
+                                               $this->globals["wg$key"][$name][] = "$dir/$file";
+                                       }
+                               }
                                $this->processed[] = $key;
                        }
                }
index 96df354..0d31878 100644 (file)
@@ -97,6 +97,33 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
                $this->assertArrayNotHasKey( 'wg@IGNORED', $extracted['globals'] );
        }
 
+       public static function provideExtractMessageSettings() {
+               $dir = __DIR__ . '/FooBar/';
+               return array(
+                       array(
+                               array( 'MessagesDirs' => array( 'VisualEditor' => 'i18n' ) ),
+                               array( 'wgMessagesDirs' => array( 'VisualEditor' => array( $dir . 'i18n' ) ) )
+                       ),
+                       array(
+                               array( 'MessagesDirs' => array( 'VisualEditor' => array( 'i18n', 'foobar' ) ) ),
+                               array( 'wgMessagesDirs' => array( 'VisualEditor' => array( $dir . 'i18n', $dir . 'foobar' ) ) )
+                       ),
+               );
+       }
+
+       /**
+        * @covers ExtensionProcessor::extractMessageSettings
+        * @dataProvider provideExtractMessageSettings
+        */
+       public function testExtractMessageSettings( $input, $expected ) {
+               $processor = new ExtensionProcessor();
+               $processor->extractInfo( $this->dir, $input + self::$default );
+               $out = $processor->getExtractedInfo();
+               foreach ( $expected as $key => $value ) {
+                       $this->assertEquals( $value, $out['globals'][$key] );
+               }
+       }
+
        public static function provideSetToGlobal() {
                return array(
                        array(