3 use Wikimedia\TestingAccessWrapper;
11 $this->dir = __DIR__ .
'/FooBar/extension.json';
12 $this->dirname = dirname( $this->dir );
30 $processor->extractInfo( $this->dir, self::$default + [
31 '@metadata' => [
'foobarbaz' ],
32 'AnAttribute' => [
'omg' ],
33 'AutoloadClasses' => [
'FooBar' =>
'includes/FooBar.php' ],
36 $extracted = $processor->getExtractedInfo();
37 $attributes = $extracted[
'attributes'];
38 $this->assertArrayHasKey(
'AnAttribute', $attributes );
39 $this->assertArrayNotHasKey(
'@metadata', $attributes );
40 $this->assertArrayNotHasKey(
'AutoloadClasses', $attributes );
60 [
'FooBaz' => [
'FooBazCallback' ] ] + $merge,
64 [
'FooBaz' => [
'PriorCallback' ] ],
66 [
'FooBaz' => [
'PriorCallback',
'FooBazCallback' ] ] + $merge,
71 [
'Hooks' => [
'FooBaz' => [
'FooBazCallback' ] ] ] +
self::$default,
72 [
'FooBaz' => [
'FooBazCallback' ] ] + $merge,
76 [
'BarBaz' => [
'BarBazCallback' ] ],
79 'BarBaz' => [
'BarBazCallback' ],
80 'FooBaz' => [
'FooBazCallback' ],
88 'FooBaz' => [
'Callback1' ],
94 [
'Hooks' => [
'FooBaz' => [
'Callback1',
'Callback2' ] ] ] +
self::$default,
96 'FooBaz' => [
'Callback1',
'Callback2' ],
108 $processor->extractInfo( $this->dir, $info, 1 );
109 $extracted = $processor->getExtractedInfo();
110 $this->assertEquals( $expected, $extracted[
'globals'][
'wgHooks'] );
120 'Bar' =>
'somevalue',
132 $processor->extractInfo( $this->dir, $info, 1 );
133 $processor->extractInfo( $this->dir, $info2, 1 );
134 $extracted = $processor->getExtractedInfo();
135 $this->assertEquals(
'somevalue', $extracted[
'globals'][
'wgBar'] );
136 $this->assertEquals( 10, $extracted[
'globals'][
'wgFoo'] );
137 $this->assertArrayNotHasKey(
'wg@IGNORED', $extracted[
'globals'] );
139 $this->assertEquals(
'somevalue', $extracted[
'globals'][
'egBar'] );
149 'Bar' => [
'value' =>
'somevalue' ],
150 'Foo' => [
'value' => 10 ],
151 'Path' => [
'value' =>
'foo.txt',
'path' =>
true ],
156 'Bar' => [
'value' =>
'somevalue' ],
158 'config_prefix' =>
'eg',
161 $processor->extractInfo( $this->dir, $info, 2 );
162 $processor->extractInfo( $this->dir, $info2, 2 );
163 $extracted = $processor->getExtractedInfo();
164 $this->assertEquals(
'somevalue', $extracted[
'globals'][
'wgBar'] );
165 $this->assertEquals( 10, $extracted[
'globals'][
'wgFoo'] );
166 $this->assertEquals(
"{$this->dirname}/foo.txt", $extracted[
'globals'][
'wgPath'] );
168 $this->assertEquals(
'somevalue', $extracted[
'globals'][
'egBar'] );
172 $dir = __DIR__ .
'/FooBar/';
175 [
'ExtensionMessagesFiles' => [
'FooBarAlias' =>
'FooBar.alias.php' ] ],
176 [
'wgExtensionMessagesFiles' => [
'FooBarAlias' =>
$dir .
'FooBar.alias.php' ] ]
180 'ExtensionMessagesFiles' => [
181 'FooBarAlias' =>
'FooBar.alias.php',
182 'FooBarMagic' =>
'FooBar.magic.i18n.php',
186 'wgExtensionMessagesFiles' => [
187 'FooBarAlias' =>
$dir .
'FooBar.alias.php',
188 'FooBarMagic' =>
$dir .
'FooBar.magic.i18n.php',
201 $processor->extractInfo( $this->dir,
$input + self::$default, 1 );
202 $out = $processor->getExtractedInfo();
203 foreach ( $expected
as $key =>
$value ) {
204 $this->assertEquals(
$value,
$out[
'globals'][$key] );
209 $dir = __DIR__ .
'/FooBar/';
212 [
'MessagesDirs' => [
'VisualEditor' =>
'i18n' ] ],
213 [
'wgMessagesDirs' => [
'VisualEditor' => [
$dir .
'i18n' ] ] ]
216 [
'MessagesDirs' => [
'VisualEditor' => [
'i18n',
'foobar' ] ] ],
217 [
'wgMessagesDirs' => [
'VisualEditor' => [
$dir .
'i18n',
$dir .
'foobar' ] ] ]
228 $processor->extractInfo( $this->dir,
$input + self::$default, 1 );
229 $out = $processor->getExtractedInfo();
230 foreach ( $expected
as $key =>
$value ) {
231 $this->assertEquals(
$value,
$out[
'globals'][$key] );
240 $processor->extractInfo( $this->dir, self::$default, 1 );
241 $this->setExpectedException(
'Exception' );
242 $processor->extractInfo( $this->dir, self::$default, 1 );
251 $processor->extractInfo( $this->dir,
$input + self::$default, 1 );
252 $out = $processor->getExtractedInfo();
253 foreach ( $expected
as $key =>
$value ) {
254 $this->assertEquals(
$value,
$out[
'globals'][$key] );
259 $dir = __DIR__ .
'/FooBar';
265 'ResourceModules' => [
267 'styles' =>
'foobar.js',
268 'localBasePath' =>
'',
269 'remoteExtPath' =>
'FooBar',
275 'wgResourceModules' => [
277 'styles' =>
'foobar.js',
278 'localBasePath' =>
$dir,
279 'remoteExtPath' =>
'FooBar',
288 'ResourceFileModulePaths' => [
289 'localBasePath' =>
'',
290 'remoteExtPath' =>
'FooBar',
292 'ResourceModules' => [
295 'styles' =>
'foo.js',
299 'styles' =>
'bar.js',
300 'localBasePath' =>
'subdir',
301 'remoteExtPath' =>
'FooBar/subdir',
305 'class' =>
'FooBarModule',
306 'extra' =>
'argument',
309 'test.class.with.path' => [
310 'class' =>
'FooBarPathModule',
311 'extra' =>
'argument',
312 'localBasePath' =>
'',
318 'wgResourceModules' => [
320 'styles' =>
'foo.js',
321 'localBasePath' =>
$dir,
322 'remoteExtPath' =>
'FooBar',
325 'styles' =>
'bar.js',
326 'localBasePath' =>
"$dir/subdir",
327 'remoteExtPath' =>
'FooBar/subdir',
330 'class' =>
'FooBarModule',
331 'extra' =>
'argument',
332 'localBasePath' =>
$dir,
333 'remoteExtPath' =>
'FooBar',
335 'test.class.with.path' => [
336 'class' =>
'FooBarPathModule',
337 'extra' =>
'argument',
338 'localBasePath' =>
$dir,
339 'remoteExtPath' =>
'FooBar',
348 'ResourceFileModulePaths' => [
349 'localBasePath' =>
'',
350 'remoteSkinPath' =>
'FooBar',
352 'ResourceModuleSkinStyles' => [
354 'test.foo' =>
'foo.css',
360 'wgResourceModuleSkinStyles' => [
362 'test.foo' =>
'foo.css',
363 'localBasePath' =>
$dir,
364 'remoteSkinPath' =>
'FooBar',
373 'ResourceFileModulePaths' => [
374 'localBasePath' =>
'',
375 'remoteSkinPath' =>
'FooBar',
377 'ResourceModuleSkinStyles' => [
379 'test.foo' =>
'foo.css',
380 'remoteSkinPath' =>
'BarFoo'
386 'wgResourceModuleSkinStyles' => [
388 'test.foo' =>
'foo.css',
389 'localBasePath' =>
$dir,
390 'remoteSkinPath' =>
'BarFoo',
401 [
'wgAPIModules',
'wgAvailableRights' ],
404 'APIModules' => [
'foobar' =>
'ApiFooBar' ],
405 'AvailableRights' => [
'foobar',
'unfoobar' ],
408 'wgAPIModules' => [
'foobar' =>
'ApiFooBar' ],
409 'wgAvailableRights' => [
'foobar',
'unfoobar' ],
413 [
'wgAPIModules',
'wgAvailableRights' ],
415 'wgAPIModules' => [
'barbaz' =>
'ApiBarBaz' ],
416 'wgAvailableRights' => [
'barbaz' ]
419 'APIModules' => [
'foobar' =>
'ApiFooBar' ],
420 'AvailableRights' => [
'foobar',
'unfoobar' ],
423 'wgAPIModules' => [
'barbaz' =>
'ApiBarBaz',
'foobar' =>
'ApiFooBar' ],
424 'wgAvailableRights' => [
'barbaz',
'foobar',
'unfoobar' ],
428 [
'wgGroupPermissions' ],
430 'wgGroupPermissions' => [
431 'sysop' => [
'delete' ]
435 'GroupPermissions' => [
436 'sysop' => [
'undelete' ],
441 'wgGroupPermissions' => [
442 'sysop' => [
'delete',
'undelete' ],
459 $processor->extractInfo( $this->dir, [
'name' =>
'FooBar' ], 2 );
460 $processor->extractInfo(
482 $info = $processor->getExtractedInfo();
483 $this->assertArrayHasKey(
'FooBarPlugins', $info[
'attributes'] );
484 $this->assertSame( [
'ext.baz.foobar' ], $info[
'attributes'][
'FooBarPlugins'] );
485 $this->assertArrayNotHasKey(
'FizzBuzzMorePlugins', $info[
'attributes'] );
495 $processor->extractInfo(
502 'FizzBuzzMorePlugins' => [
509 $info = $processor->getExtractedInfo();
510 $this->assertArrayHasKey(
'FooBarPlugins', $info[
'attributes'] );
511 $this->assertSame( [
'ext.baz.foobar' ], $info[
'attributes'][
'FooBarPlugins'] );
512 $this->assertArrayHasKey(
'FizzBuzzMorePlugins', $info[
'attributes'] );
513 $this->assertSame( [
'ext.baz.fizzbuzz' ], $info[
'attributes'][
'FizzBuzzMorePlugins'] );
518 $globalSettings = TestingAccessWrapper::newFromClass(
523 file_get_contents(
"$IP/docs/extension.schema.v$version.json" ),
527 foreach ( $globalSettings
as $global ) {
528 if ( !isset( $schema[
'properties'][$global] ) ) {
529 $missing[] = $global;
533 $this->assertEquals( [], $missing,
534 "The following global settings are not documented in docs/extension.schema.json" );