X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fregistration%2FExtensionRegistryTest.php;h=167f52a16fe8987486183aa8350b7a02cd533daf;hb=46202ee2b218e7f2813ec97ece046b4850fd78a7;hp=201cbfcdf1191ffdca81d954f4fb5a433808a10e;hpb=1271bb75c60f98720a24ed1bac13a48f2181fb00;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/registration/ExtensionRegistryTest.php b/tests/phpunit/includes/registration/ExtensionRegistryTest.php index 201cbfcdf1..167f52a16f 100644 --- a/tests/phpunit/includes/registration/ExtensionRegistryTest.php +++ b/tests/phpunit/includes/registration/ExtensionRegistryTest.php @@ -19,18 +19,19 @@ class ExtensionRegistryTest extends MediaWikiTestCase { } } - $info = array( + $info = [ 'globals' => $globals, - 'callbacks' => array(), - 'defines' => array(), - 'credits' => array(), - 'attributes' => array(), - ); + 'callbacks' => [], + 'defines' => [], + 'credits' => [], + 'attributes' => [], + 'autoloaderPaths' => [] + ]; $registry = new ExtensionRegistry(); $class = new ReflectionClass( 'ExtensionRegistry' ); $method = $class->getMethod( 'exportExtractedData' ); $method->setAccessible( true ); - $method->invokeArgs( $registry, array( $info ) ); + $method->invokeArgs( $registry, [ $info ] ); foreach ( $expected as $name => $value ) { $this->assertArrayHasKey( $name, $GLOBALS, $desc ); $this->assertEquals( $value, $GLOBALS[$name], $desc ); @@ -48,209 +49,209 @@ class ExtensionRegistryTest extends MediaWikiTestCase { public static function provideExportExtractedDataGlobals() { // "mwtest" prefix used instead of "$wg" to avoid potential conflicts - return array( - array( + return [ + [ 'Simple non-array values', - array( + [ 'mwtestFooBarConfig' => true, 'mwtestFooBarConfig2' => 'string', - ), - array( + ], + [ 'mwtestFooBarDefault' => 1234, 'mwtestFooBarConfig' => false, - ), - array( + ], + [ 'mwtestFooBarConfig' => true, 'mwtestFooBarConfig2' => 'string', 'mwtestFooBarDefault' => 1234, - ), - ), - array( + ], + ], + [ 'No global already set, simple array', null, - array( - 'mwtestDefaultOptions' => array( + [ + 'mwtestDefaultOptions' => [ 'foobar' => true, - ) - ), - array( - 'mwtestDefaultOptions' => array( + ] + ], + [ + 'mwtestDefaultOptions' => [ 'foobar' => true, - ) - ), - ), - array( + ] + ], + ], + [ 'Global already set, simple array', - array( - 'mwtestDefaultOptions' => array( + [ + 'mwtestDefaultOptions' => [ 'foobar' => true, 'foo' => 'string' - ), - ), - array( - 'mwtestDefaultOptions' => array( + ], + ], + [ + 'mwtestDefaultOptions' => [ 'barbaz' => 12345, 'foobar' => false, - ), - ), - array( - 'mwtestDefaultOptions' => array( + ], + ], + [ + 'mwtestDefaultOptions' => [ 'barbaz' => 12345, 'foo' => 'string', 'foobar' => true, - ), - ) - ), - array( + ], + ] + ], + [ 'Global already set, 1d array that appends', - array( - 'mwAvailableRights' => array( + [ + 'mwAvailableRights' => [ 'foobar', 'foo' - ), - ), - array( - 'mwAvailableRights' => array( + ], + ], + [ + 'mwAvailableRights' => [ 'barbaz', - ), - ), - array( - 'mwAvailableRights' => array( + ], + ], + [ + 'mwAvailableRights' => [ 'barbaz', 'foobar', 'foo', - ), - ) - ), - array( + ], + ] + ], + [ 'Global already set, array with integer keys', - array( - 'mwNamespacesFoo' => array( + [ + 'mwNamespacesFoo' => [ 100 => true, 102 => false - ), - ), - array( - 'mwNamespacesFoo' => array( + ], + ], + [ + 'mwNamespacesFoo' => [ 100 => false, 500 => true, ExtensionRegistry::MERGE_STRATEGY => 'array_plus', - ), - ), - array( - 'mwNamespacesFoo' => array( + ], + ], + [ + 'mwNamespacesFoo' => [ 100 => true, 102 => false, 500 => true, - ), - ) - ), - array( + ], + ] + ], + [ 'No global already set, $wgHooks', - array( - 'wgHooks' => array(), - ), - array( - 'wgHooks' => array( - 'FooBarEvent' => array( + [ + 'wgHooks' => [], + ], + [ + 'wgHooks' => [ + 'FooBarEvent' => [ 'FooBarClass::onFooBarEvent' - ), + ], ExtensionRegistry::MERGE_STRATEGY => 'array_merge_recursive' - ), - ), - array( - 'wgHooks' => array( - 'FooBarEvent' => array( + ], + ], + [ + 'wgHooks' => [ + 'FooBarEvent' => [ 'FooBarClass::onFooBarEvent' - ), - ), - ), - ), - array( + ], + ], + ], + ], + [ 'Global already set, $wgHooks', - array( - 'wgHooks' => array( - 'FooBarEvent' => array( + [ + 'wgHooks' => [ + 'FooBarEvent' => [ 'FooBarClass::onFooBarEvent' - ), - 'BazBarEvent' => array( + ], + 'BazBarEvent' => [ 'FooBarClass::onBazBarEvent', - ), - ), - ), - array( - 'wgHooks' => array( - 'FooBarEvent' => array( + ], + ], + ], + [ + 'wgHooks' => [ + 'FooBarEvent' => [ 'BazBarClass::onFooBarEvent', - ), + ], ExtensionRegistry::MERGE_STRATEGY => 'array_merge_recursive', - ), - ), - array( - 'wgHooks' => array( - 'FooBarEvent' => array( + ], + ], + [ + 'wgHooks' => [ + 'FooBarEvent' => [ 'FooBarClass::onFooBarEvent', 'BazBarClass::onFooBarEvent', - ), - 'BazBarEvent' => array( + ], + 'BazBarEvent' => [ 'FooBarClass::onBazBarEvent', - ), - ), - ), - ), - array( + ], + ], + ], + ], + [ 'Global already set, $wgGroupPermissions', - array( - 'wgGroupPermissions' => array( - 'sysop' => array( + [ + 'wgGroupPermissions' => [ + 'sysop' => [ 'something' => true, - ), - 'user' => array( + ], + 'user' => [ 'somethingtwo' => true, - ) - ), - ), - array( - 'wgGroupPermissions' => array( - 'customgroup' => array( + ] + ], + ], + [ + 'wgGroupPermissions' => [ + 'customgroup' => [ 'right' => true, - ), - 'user' => array( + ], + 'user' => [ 'right' => true, 'somethingtwo' => false, 'nonduplicated' => true, - ), + ], ExtensionRegistry::MERGE_STRATEGY => 'array_plus_2d', - ), - ), - array( - 'wgGroupPermissions' => array( - 'customgroup' => array( + ], + ], + [ + 'wgGroupPermissions' => [ + 'customgroup' => [ 'right' => true, - ), - 'sysop' => array( + ], + 'sysop' => [ 'something' => true, - ), - 'user' => array( + ], + 'user' => [ 'somethingtwo' => true, 'right' => true, 'nonduplicated' => true, - ) - ), - ), - ), - array( + ] + ], + ], + ], + [ 'False local setting should not be overridden (T100767)', - array( + [ 'mwtestT100767' => false, - ), - array( + ], + [ 'mwtestT100767' => true, - ), - array( + ], + [ 'mwtestT100767' => false, - ), - ), - ); + ], + ], + ]; } }