Merge "DatabaseMssql: Don't duplicate body of makeList()"
[lhc/web/wiklou.git] / tests / phpunit / includes / registration / ExtensionRegistryTest.php
1 <?php
2
3 class ExtensionRegistryTest extends MediaWikiTestCase {
4
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;
14 }
15 }
16 $info = array(
17 'globals' => $globals,
18 'callbacks' => array(),
19 'defines' => array(),
20 'credits' => array(),
21 'attributes' => array(),
22 );
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 );
31 }
32 }
33
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',
42 ),
43 array(
44 'mwtestFooBarDefault' => 1234,
45 'mwtestFooBarConfig' => false,
46 ),
47 array(
48 'mwtestFooBarConfig' => true,
49 'mwtestFooBarConfig2' => 'string',
50 'mwtestFooBarDefault' => 1234,
51 ),
52 ),
53 array(
54 'No global already set, simple array',
55 null,
56 array(
57 'mwtestDefaultOptions' => array(
58 'foobar' => true,
59 )
60 ),
61 array(
62 'mwtestDefaultOptions' => array(
63 'foobar' => true,
64 )
65 ),
66 ),
67 array(
68 'Global already set, simple array',
69 array(
70 'mwtestDefaultOptions' => array(
71 'foobar' => true,
72 'foo' => 'string'
73 ),
74 ),
75 array(
76 'mwtestDefaultOptions' => array(
77 'barbaz' => 12345,
78 'foobar' => false,
79 ),
80 ),
81 array(
82 'mwtestDefaultOptions' => array(
83 'barbaz' => 12345,
84 'foo' => 'string',
85 'foobar' => true,
86 ),
87 )
88 ),
89 array(
90 'No global already set, $wgHooks',
91 array(
92 'wgHooks' => array(),
93 ),
94 array(
95 'wgHooks' => array(
96 'FooBarEvent' => array(
97 'FooBarClass::onFooBarEvent'
98 ),
99 ),
100 ),
101 array(
102 'wgHooks' => array(
103 'FooBarEvent' => array(
104 'FooBarClass::onFooBarEvent'
105 ),
106 ),
107 ),
108 ),
109 array(
110 'Global already set, $wgHooks',
111 array(
112 'wgHooks' => array(
113 'FooBarEvent' => array(
114 'FooBarClass::onFooBarEvent'
115 ),
116 'BazBarEvent' => array(
117 'FooBarClass::onBazBarEvent',
118 ),
119 ),
120 ),
121 array(
122 'wgHooks' => array(
123 'FooBarEvent' => array(
124 'BazBarClass::onFooBarEvent',
125 ),
126 ),
127 ),
128 array(
129 'wgHooks' => array(
130 'FooBarEvent' => array(
131 'FooBarClass::onFooBarEvent',
132 'BazBarClass::onFooBarEvent',
133 ),
134 'BazBarEvent' => array(
135 'FooBarClass::onBazBarEvent',
136 ),
137 ),
138 ),
139 ),
140 array(
141 'Global already set, $wgGroupPermissions',
142 array(
143 'wgGroupPermissions' => array(
144 'sysop' => array(
145 'something' => true,
146 ),
147 'user' => array(
148 'somethingtwo' => true,
149 )
150 ),
151 ),
152 array(
153 'wgGroupPermissions' => array(
154 'customgroup' => array(
155 'right' => true,
156 ),
157 'user' => array(
158 'right' => true,
159 'somethingtwo' => false,
160 )
161 ),
162 ),
163 array(
164 'wgGroupPermissions' => array(
165 'customgroup' => array(
166 'right' => true,
167 ),
168 'sysop' => array(
169 'something' => true,
170 ),
171 'user' => array(
172 'somethingtwo' => true,
173 'right' => true,
174 )
175 ),
176 ),
177 )
178 );
179 }
180 }