+ public function testAttributes1_notarray() {
+ $processor = new ExtensionProcessor();
+ $this->setExpectedException(
+ InvalidArgumentException::class,
+ "The value for 'FooBarPlugins' should be an array (from {$this->dir})"
+ );
+ $processor->extractInfo(
+ $this->dir,
+ [
+ 'FooBarPlugins' => 'ext.baz.foobar',
+ ] + self::$default,
+ 1
+ );
+ }
+
+ public function testExtractPathBasedGlobal() {
+ $processor = new ExtensionProcessor();
+ $processor->extractInfo(
+ $this->dir,
+ [
+ 'ParserTestFiles' => [
+ 'tests/parserTests.txt',
+ 'tests/extraParserTests.txt',
+ ],
+ 'ServiceWiringFiles' => [
+ 'includes/ServiceWiring.php'
+ ],
+ ] + self::$default,
+ 1
+ );
+ $globals = $processor->getExtractedInfo()['globals'];
+ $this->assertArrayHasKey( 'wgParserTestFiles', $globals );
+ $this->assertSame( [
+ "{$this->dirname}/tests/parserTests.txt",
+ "{$this->dirname}/tests/extraParserTests.txt"
+ ], $globals['wgParserTestFiles'] );
+ $this->assertArrayHasKey( 'wgServiceWiringFiles', $globals );
+ $this->assertSame( [
+ "{$this->dirname}/includes/ServiceWiring.php"
+ ], $globals['wgServiceWiringFiles'] );
+ }
+
+ public function testGetRequirements() {
+ $info = self::$default + [
+ 'requires' => [
+ 'MediaWiki' => '>= 1.25.0',
+ 'platform' => [
+ 'php' => '>= 5.5.9'
+ ],
+ 'extensions' => [
+ 'Bar' => '*'
+ ]
+ ]
+ ];
+ $processor = new ExtensionProcessor();
+ $this->assertSame(
+ $info['requires'],
+ $processor->getRequirements( $info, false )
+ );
+ $this->assertSame(
+ [],
+ $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 )
+ );
+ }
+
+ public function testGetExtraAutoloaderPaths() {
+ $processor = new ExtensionProcessor();
+ $this->assertSame(
+ [ "{$this->dirname}/vendor/autoload.php" ],
+ $processor->getExtraAutoloaderPaths( $this->dirname, [
+ 'load_composer_autoloader' => true,
+ ] )
+ );
+ }
+
+ /**
+ * Verify that extension.schema.json is in sync with ExtensionProcessor
+ *
+ * @coversNothing
+ */