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 'No global already set, $wgHooks',
107 'wgHooks' => array(),
111 'FooBarEvent' => array(
112 'FooBarClass::onFooBarEvent'
118 'FooBarEvent' => array(
119 'FooBarClass::onFooBarEvent'
125 'Global already set, $wgHooks',
128 'FooBarEvent' => array(
129 'FooBarClass::onFooBarEvent'
131 'BazBarEvent' => array(
132 'FooBarClass::onBazBarEvent',
138 'FooBarEvent' => array(
139 'BazBarClass::onFooBarEvent',
145 'FooBarEvent' => array(
146 'FooBarClass::onFooBarEvent',
147 'BazBarClass::onFooBarEvent',
149 'BazBarEvent' => array(
150 'FooBarClass::onBazBarEvent',
156 'Global already set, $wgGroupPermissions',
158 'wgGroupPermissions' => array(
163 'somethingtwo' => true,
168 'wgGroupPermissions' => array(
169 'customgroup' => array(
174 'somethingtwo' => false,
179 'wgGroupPermissions' => array(
180 'customgroup' => array(
187 'somethingtwo' => true,