Merge "ApiQueryRevisions: Fix error message key"
[lhc/web/wiklou.git] / tests / phpunit / includes / registration / ExtensionProcessorTest.php
index ef19b2f..cdd5c63 100644 (file)
@@ -357,13 +357,20 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
        /**
         * @dataProvider provideExtractResourceLoaderModules
         */
-       public function testExtractResourceLoaderModules( $input, $expected ) {
+       public function testExtractResourceLoaderModules(
+               $input,
+               array $expectedGlobals,
+               array $expectedAttribs = []
+       ) {
                $processor = new ExtensionProcessor();
                $processor->extractInfo( $this->dir, $input + self::$default, 1 );
                $out = $processor->getExtractedInfo();
-               foreach ( $expected as $key => $value ) {
+               foreach ( $expectedGlobals as $key => $value ) {
                        $this->assertEquals( $value, $out['globals'][$key] );
                }
+               foreach ( $expectedAttribs as $key => $value ) {
+                       $this->assertEquals( $value, $out['attributes'][$key] );
+               }
        }
 
        public static function provideExtractResourceLoaderModules() {
@@ -503,6 +510,27 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
                                        ],
                                ],
                        ],
+                       'QUnit test module' => [
+                               // Input
+                               [
+                                       'QUnitTestModule' => [
+                                               'localBasePath' => '',
+                                               'remoteExtPath' => 'Foo',
+                                               'scripts' => 'bar.js',
+                                       ],
+                               ],
+                               // Expected
+                               [],
+                               [
+                                       'QUnitTestModules' => [
+                                               'test.FooBar' => [
+                                                       'localBasePath' => $dir,
+                                                       'remoteExtPath' => 'Foo',
+                                                       'scripts' => 'bar.js',
+                                               ],
+                                       ],
+                               ],
+                       ],
                ];
        }
 
@@ -647,7 +675,7 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
                );
        }
 
-       public function testExtractSimplePathBased() {
+       public function testExtractPathBasedGlobal() {
                $processor = new ExtensionProcessor();
                $processor->extractInfo(
                        $this->dir,
@@ -678,6 +706,9 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
                $info = self::$default + [
                        'requires' => [
                                'MediaWiki' => '>= 1.25.0',
+                               'platform' => [
+                                       'php' => '>= 5.5.9'
+                               ],
                                'extensions' => [
                                        'Bar' => '*'
                                ]
@@ -686,11 +717,67 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
                $processor = new ExtensionProcessor();
                $this->assertSame(
                        $info['requires'],
-                       $processor->getRequirements( $info )
+                       $processor->getRequirements( $info, false )
                );
                $this->assertSame(
                        [],
-                       $processor->getRequirements( [] )
+                       $processor->getRequirements( [], false )
+               );
+       }
+
+       public function testGetDevRequirements() {
+               $info = self::$default + [
+                       'dev-requires' => [
+                               'MediaWiki' => '>= 1.31.0',
+                               'platform' => [
+                                       'ext-foo' => '*',
+                               ],
+                               'skins' => [
+                                       'Baz' => '*',
+                               ],
+                               'extensions' => [
+                                       'Biz' => '*',
+                               ],
+                       ],
+               ];
+               $processor = new ExtensionProcessor();
+               $this->assertSame(
+                       $info['dev-requires'],
+                       $processor->getRequirements( $info, true )
+               );
+               // Set some standard requirements, so we can test merging
+               $info['requires'] = [
+                       'MediaWiki' => '>= 1.25.0',
+                       'platform' => [
+                               'php' => '>= 5.5.9'
+                       ],
+                       'extensions' => [
+                               'Bar' => '*'
+                       ]
+               ];
+               $this->assertSame(
+                       [
+                               'MediaWiki' => '>= 1.25.0 >= 1.31.0',
+                               'platform' => [
+                                       'php' => '>= 5.5.9',
+                                       'ext-foo' => '*',
+                               ],
+                               'extensions' => [
+                                       'Bar' => '*',
+                                       'Biz' => '*',
+                               ],
+                               'skins' => [
+                                       'Baz' => '*',
+                               ],
+                       ],
+                       $processor->getRequirements( $info, true )
+               );
+
+               // If there's no dev-requires, it just returns requires
+               unset( $info['dev-requires'] );
+               $this->assertSame(
+                       $info['requires'],
+                       $processor->getRequirements( $info, true )
                );
        }