Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / tests / phpunit / includes / registration / ExtensionRegistryTest.php
blob421cab5b281fbfc6ee818dfaf590b76c365c67d1
1 <?php
3 class ExtensionRegistryTest extends MediaWikiTestCase {
5 /**
6 * @covers ExtensionRegistry::exportExtractedData
7 * @dataProvider provideExportExtractedDataGlobals
8 * @@backupGlobals enabled
9 */
10 public function testExportExtractedDataGlobals( $desc, $before, $globals, $expected ) {
11 if ( $before ) {
12 foreach ( $before as $key => $value ) {
13 $GLOBALS[$key] = $value;
16 $info = array(
17 'globals' => $globals,
18 'callbacks' => array(),
19 'defines' => array(),
20 'credits' => array(),
21 'attributes' => array(),
23 $registry = new ExtensionRegistry();
24 $class = new ReflectionClass( 'ExtensionRegistry' );
25 $method = $class->getMethod( 'exportExtractedData' );
26 $method->setAccessible( true );
27 $method->invokeArgs( $registry, array( $info ) );
28 foreach ( $expected as $name => $value ) {
29 $this->assertArrayHasKey( $name, $GLOBALS, $desc );
30 $this->assertEquals( $value, $GLOBALS[$name], $desc );
34 public static function provideExportExtractedDataGlobals() {
35 // "mwtest" prefix used instead of "$wg" to avoid potential conflicts
36 return array(
37 array(
38 'Simple non-array values',
39 array(
40 'mwtestFooBarConfig' => true,
41 'mwtestFooBarConfig2' => 'string',
43 array(
44 'mwtestFooBarDefault' => 1234,
45 'mwtestFooBarConfig' => false,
47 array(
48 'mwtestFooBarConfig' => true,
49 'mwtestFooBarConfig2' => 'string',
50 'mwtestFooBarDefault' => 1234,
53 array(
54 'No global already set, simple array',
55 null,
56 array(
57 'mwtestDefaultOptions' => array(
58 'foobar' => true,
61 array(
62 'mwtestDefaultOptions' => array(
63 'foobar' => true,
67 array(
68 'Global already set, simple array',
69 array(
70 'mwtestDefaultOptions' => array(
71 'foobar' => true,
72 'foo' => 'string'
75 array(
76 'mwtestDefaultOptions' => array(
77 'barbaz' => 12345,
78 'foobar' => false,
81 array(
82 'mwtestDefaultOptions' => array(
83 'barbaz' => 12345,
84 'foo' => 'string',
85 'foobar' => true,
89 array(
90 'No global already set, $wgHooks',
91 array(
92 'wgHooks' => array(),
94 array(
95 'wgHooks' => array(
96 'FooBarEvent' => array(
97 'FooBarClass::onFooBarEvent'
101 array(
102 'wgHooks' => array(
103 'FooBarEvent' => array(
104 'FooBarClass::onFooBarEvent'
109 array(
110 'Global already set, $wgHooks',
111 array(
112 'wgHooks' => array(
113 'FooBarEvent' => array(
114 'FooBarClass::onFooBarEvent'
116 'BazBarEvent' => array(
117 'FooBarClass::onBazBarEvent',
121 array(
122 'wgHooks' => array(
123 'FooBarEvent' => array(
124 'BazBarClass::onFooBarEvent',
128 array(
129 'wgHooks' => array(
130 'FooBarEvent' => array(
131 'FooBarClass::onFooBarEvent',
132 'BazBarClass::onFooBarEvent',
134 'BazBarEvent' => array(
135 'FooBarClass::onBazBarEvent',
140 array(
141 'Global already set, $wgGroupPermissions',
142 array(
143 'wgGroupPermissions' => array(
144 'sysop' => array(
145 'something' => true,
147 'user' => array(
148 'somethingtwo' => true,
152 array(
153 'wgGroupPermissions' => array(
154 'customgroup' => array(
155 'right' => true,
157 'user' => array(
158 'right' => true,
159 'somethingtwo' => false,
163 array(
164 'wgGroupPermissions' => array(
165 'customgroup' => array(
166 'right' => true,
168 'sysop' => array(
169 'something' => true,
171 'user' => array(
172 'somethingtwo' => true,
173 'right' => true,