Import: Handle uploads with sha1 starting with 0 properly
[mediawiki.git] / tests / phpunit / includes / registration / ExtensionRegistryTest.php
blob543eb5c78d76eca1d4da1594aecd168e747ecc94
1 <?php
3 class ExtensionRegistryTest extends MediaWikiTestCase {
5 /**
6 * @covers ExtensionRegistry::exportExtractedData
7 * @dataProvider provideExportExtractedDataGlobals
8 */
9 public function testExportExtractedDataGlobals( $desc, $before, $globals, $expected ) {
10 // Set globals for test
11 if ( $before ) {
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;
16 } else {
17 $this->setMwGlobals( $key, $value );
22 $info = array(
23 'globals' => $globals,
24 'callbacks' => array(),
25 'defines' => array(),
26 'credits' => array(),
27 'attributes' => array(),
28 'autoloaderPaths' => array()
30 $registry = new ExtensionRegistry();
31 $class = new ReflectionClass( 'ExtensionRegistry' );
32 $method = $class->getMethod( 'exportExtractedData' );
33 $method->setAccessible( true );
34 $method->invokeArgs( $registry, array( $info ) );
35 foreach ( $expected as $name => $value ) {
36 $this->assertArrayHasKey( $name, $GLOBALS, $desc );
37 $this->assertEquals( $value, $GLOBALS[$name], $desc );
40 // Remove mw prefixed globals
41 if ( $before ) {
42 foreach ( $before as $key => $value ) {
43 if ( substr( $key, 0, 2 ) == 'mw' ) {
44 unset( $GLOBALS[$key] );
50 public static function provideExportExtractedDataGlobals() {
51 // "mwtest" prefix used instead of "$wg" to avoid potential conflicts
52 return array(
53 array(
54 'Simple non-array values',
55 array(
56 'mwtestFooBarConfig' => true,
57 'mwtestFooBarConfig2' => 'string',
59 array(
60 'mwtestFooBarDefault' => 1234,
61 'mwtestFooBarConfig' => false,
63 array(
64 'mwtestFooBarConfig' => true,
65 'mwtestFooBarConfig2' => 'string',
66 'mwtestFooBarDefault' => 1234,
69 array(
70 'No global already set, simple array',
71 null,
72 array(
73 'mwtestDefaultOptions' => array(
74 'foobar' => true,
77 array(
78 'mwtestDefaultOptions' => array(
79 'foobar' => true,
83 array(
84 'Global already set, simple array',
85 array(
86 'mwtestDefaultOptions' => array(
87 'foobar' => true,
88 'foo' => 'string'
91 array(
92 'mwtestDefaultOptions' => array(
93 'barbaz' => 12345,
94 'foobar' => false,
97 array(
98 'mwtestDefaultOptions' => array(
99 'barbaz' => 12345,
100 'foo' => 'string',
101 'foobar' => true,
105 array(
106 'Global already set, 1d array that appends',
107 array(
108 'mwAvailableRights' => array(
109 'foobar',
110 'foo'
113 array(
114 'mwAvailableRights' => array(
115 'barbaz',
118 array(
119 'mwAvailableRights' => array(
120 'barbaz',
121 'foobar',
122 'foo',
126 array(
127 'Global already set, array with integer keys',
128 array(
129 'mwNamespacesFoo' => array(
130 100 => true,
131 102 => false
134 array(
135 'mwNamespacesFoo' => array(
136 100 => false,
137 500 => true,
138 ExtensionRegistry::MERGE_STRATEGY => 'array_plus',
141 array(
142 'mwNamespacesFoo' => array(
143 100 => true,
144 102 => false,
145 500 => true,
149 array(
150 'No global already set, $wgHooks',
151 array(
152 'wgHooks' => array(),
154 array(
155 'wgHooks' => array(
156 'FooBarEvent' => array(
157 'FooBarClass::onFooBarEvent'
159 ExtensionRegistry::MERGE_STRATEGY => 'array_merge_recursive'
162 array(
163 'wgHooks' => array(
164 'FooBarEvent' => array(
165 'FooBarClass::onFooBarEvent'
170 array(
171 'Global already set, $wgHooks',
172 array(
173 'wgHooks' => array(
174 'FooBarEvent' => array(
175 'FooBarClass::onFooBarEvent'
177 'BazBarEvent' => array(
178 'FooBarClass::onBazBarEvent',
182 array(
183 'wgHooks' => array(
184 'FooBarEvent' => array(
185 'BazBarClass::onFooBarEvent',
187 ExtensionRegistry::MERGE_STRATEGY => 'array_merge_recursive',
190 array(
191 'wgHooks' => array(
192 'FooBarEvent' => array(
193 'FooBarClass::onFooBarEvent',
194 'BazBarClass::onFooBarEvent',
196 'BazBarEvent' => array(
197 'FooBarClass::onBazBarEvent',
202 array(
203 'Global already set, $wgGroupPermissions',
204 array(
205 'wgGroupPermissions' => array(
206 'sysop' => array(
207 'something' => true,
209 'user' => array(
210 'somethingtwo' => true,
214 array(
215 'wgGroupPermissions' => array(
216 'customgroup' => array(
217 'right' => true,
219 'user' => array(
220 'right' => true,
221 'somethingtwo' => false,
222 'nonduplicated' => true,
224 ExtensionRegistry::MERGE_STRATEGY => 'array_plus_2d',
227 array(
228 'wgGroupPermissions' => array(
229 'customgroup' => array(
230 'right' => true,
232 'sysop' => array(
233 'something' => true,
235 'user' => array(
236 'somethingtwo' => true,
237 'right' => true,
238 'nonduplicated' => true,
243 array(
244 'False local setting should not be overridden (T100767)',
245 array(
246 'mwtestT100767' => false,
248 array(
249 'mwtestT100767' => true,
251 array(
252 'mwtestT100767' => false,