3 class ExtensionRegistryTest
extends MediaWikiTestCase
{
6 * @covers ExtensionRegistry::exportExtractedData
7 * @dataProvider provideExportExtractedDataGlobals
9 public function testExportExtractedDataGlobals( $desc, $before, $globals, $expected ) {
10 // Set globals for test
12 foreach ( $before as $key => $value ) {
13 // mw prefixed globals does not exist normally
14 if ( substr( $key, 0, 2 ) == 'mw' ) {
15 $GLOBALS[$key] = $value;
17 $this->setMwGlobals( $key, $value );
23 'globals' => $globals,
24 'callbacks' => array(),
27 'attributes' => array(),
29 $registry = new ExtensionRegistry();
30 $class = new ReflectionClass( 'ExtensionRegistry' );
31 $method = $class->getMethod( 'exportExtractedData' );
32 $method->setAccessible( true );
33 $method->invokeArgs( $registry, array( $info ) );
34 foreach ( $expected as $name => $value ) {
35 $this->assertArrayHasKey( $name, $GLOBALS, $desc );
36 $this->assertEquals( $value, $GLOBALS[$name], $desc );
39 // Remove mw prefixed globals
41 foreach ( $before as $key => $value ) {
42 if ( substr( $key, 0, 2 ) == 'mw' ) {
43 unset( $GLOBALS[$key] );
49 public static function provideExportExtractedDataGlobals() {
50 // "mwtest" prefix used instead of "$wg" to avoid potential conflicts
53 'Simple non-array values',
55 'mwtestFooBarConfig' => true,
56 'mwtestFooBarConfig2' => 'string',
59 'mwtestFooBarDefault' => 1234,
60 'mwtestFooBarConfig' => false,
63 'mwtestFooBarConfig' => true,
64 'mwtestFooBarConfig2' => 'string',
65 'mwtestFooBarDefault' => 1234,
69 'No global already set, simple array',
72 'mwtestDefaultOptions' => array(
77 'mwtestDefaultOptions' => array(
83 'Global already set, simple array',
85 'mwtestDefaultOptions' => array(
91 'mwtestDefaultOptions' => array(
97 'mwtestDefaultOptions' => array(
105 'Global already set, 1d array that appends',
107 'mwAvailableRights' => array(
113 'mwAvailableRights' => array(
118 'mwAvailableRights' => array(
126 'Global already set, 2d array with integer keys',
128 'mwNamespacesFoo' => array(
134 'mwNamespacesFoo' => array(
137 ExtensionRegistry
::MERGE_STRATEGY
=> 'array_plus',
141 'mwNamespacesFoo' => array(
149 'No global already set, $wgHooks',
151 'wgHooks' => array(),
155 'FooBarEvent' => array(
156 'FooBarClass::onFooBarEvent'
158 ExtensionRegistry
::MERGE_STRATEGY
=> 'array_merge_recursive'
163 'FooBarEvent' => array(
164 'FooBarClass::onFooBarEvent'
170 'Global already set, $wgHooks',
173 'FooBarEvent' => array(
174 'FooBarClass::onFooBarEvent'
176 'BazBarEvent' => array(
177 'FooBarClass::onBazBarEvent',
183 'FooBarEvent' => array(
184 'BazBarClass::onFooBarEvent',
186 ExtensionRegistry
::MERGE_STRATEGY
=> 'array_merge_recursive',
191 'FooBarEvent' => array(
192 'FooBarClass::onFooBarEvent',
193 'BazBarClass::onFooBarEvent',
195 'BazBarEvent' => array(
196 'FooBarClass::onBazBarEvent',
202 'Global already set, $wgGroupPermissions',
204 'wgGroupPermissions' => array(
209 'somethingtwo' => true,
214 'wgGroupPermissions' => array(
215 'customgroup' => array(
220 'somethingtwo' => false,
221 'nonduplicated' => true,
223 ExtensionRegistry
::MERGE_STRATEGY
=> 'array_plus_2d',
227 'wgGroupPermissions' => array(
228 'customgroup' => array(
235 'somethingtwo' => true,
237 'nonduplicated' => true,
243 'False local setting should not be overridden (T100767)',
245 'mwtestT100767' => false,
248 'mwtestT100767' => true,
251 'mwtestT100767' => false,