X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fregistration%2FExtensionProcessorTest.php;h=cdd5c63eff5929a2b974b9954a0753694cda6c0d;hb=5c88c989328b38b7c2127af83f890d06bbe134af;hp=71a3a4fa8050c33c48630c2ba6920ee821b0839a;hpb=1dee28cb5f1efd6d9e14d6cc1d0c73c3f69269b4;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/registration/ExtensionProcessorTest.php b/tests/phpunit/includes/registration/ExtensionProcessorTest.php index 71a3a4fa80..cdd5c63eff 100644 --- a/tests/phpunit/includes/registration/ExtensionProcessorTest.php +++ b/tests/phpunit/includes/registration/ExtensionProcessorTest.php @@ -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', + ], + ], + ], + ], ]; } @@ -689,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 ) ); }