Merge "Fix name of Tunisian Arabic language in Latin script"
[lhc/web/wiklou.git] / tests / phpunit / includes / logging / BlockLogFormatterTest.php
1 <?php
2
3 class BlockLogFormatterTest extends LogFormatterTestCase {
4
5 /**
6 * Provide different rows from the logging table to test
7 * for backward compatibility.
8 * Do not change the existing data, just add a new database row
9 */
10 public static function provideBlockLogDatabaseRows() {
11 return array(
12 // Current log format
13 array(
14 array(
15 'type' => 'block',
16 'action' => 'block',
17 'comment' => 'Block comment',
18 'user' => 0,
19 'user_text' => 'Sysop',
20 'namespace' => NS_USER,
21 'title' => 'Logtestuser',
22 'params' => array(
23 '5::duration' => 'infinite',
24 '6::flags' => 'anononly',
25 ),
26 ),
27 array(
28 'text' => 'Sysop blocked Logtestuser with an expiry time of indefinite (anonymous users only)',
29 'api' => array(
30 'duration' => 'infinite',
31 'flags' => array( 'anononly' ),
32 ),
33 ),
34 ),
35
36 // Old legacy log
37 array(
38 array(
39 'type' => 'block',
40 'action' => 'block',
41 'comment' => 'Block comment',
42 'user' => 0,
43 'user_text' => 'Sysop',
44 'namespace' => NS_USER,
45 'title' => 'Logtestuser',
46 'params' => array(
47 'infinite',
48 'anononly',
49 ),
50 ),
51 array(
52 'legacy' => true,
53 'text' => 'Sysop blocked Logtestuser with an expiry time of indefinite (anonymous users only)',
54 'api' => array(
55 'duration' => 'infinite',
56 'flags' => array( 'anononly' ),
57 ),
58 ),
59 ),
60
61 // Old legacy log without flag
62 array(
63 array(
64 'type' => 'block',
65 'action' => 'block',
66 'comment' => 'Block comment',
67 'user' => 0,
68 'user_text' => 'Sysop',
69 'namespace' => NS_USER,
70 'title' => 'Logtestuser',
71 'params' => array(
72 'infinite',
73 ),
74 ),
75 array(
76 'legacy' => true,
77 'text' => 'Sysop blocked Logtestuser with an expiry time of indefinite',
78 'api' => array(
79 'duration' => 'infinite',
80 'flags' => array(),
81 ),
82 ),
83 ),
84
85 // Very old legacy log without duration
86 array(
87 array(
88 'type' => 'block',
89 'action' => 'block',
90 'comment' => 'Block comment',
91 'user' => 0,
92 'user_text' => 'Sysop',
93 'namespace' => NS_USER,
94 'title' => 'Logtestuser',
95 'params' => array(),
96 ),
97 array(
98 'legacy' => true,
99 'text' => 'Sysop blocked Logtestuser with an expiry time of indefinite',
100 'api' => array(
101 'duration' => 'infinite',
102 'flags' => array(),
103 ),
104 ),
105 ),
106 );
107 }
108
109 /**
110 * @dataProvider provideBlockLogDatabaseRows
111 */
112 public function testBlockLogDatabaseRows( $row, $extra ) {
113 $this->doTestLogFormatter( $row, $extra );
114 }
115
116 /**
117 * Provide different rows from the logging table to test
118 * for backward compatibility.
119 * Do not change the existing data, just add a new database row
120 */
121 public static function provideReblockLogDatabaseRows() {
122 return array(
123 // Current log format
124 array(
125 array(
126 'type' => 'block',
127 'action' => 'reblock',
128 'comment' => 'Block comment',
129 'user' => 0,
130 'user_text' => 'Sysop',
131 'namespace' => NS_USER,
132 'title' => 'Logtestuser',
133 'params' => array(
134 '5::duration' => 'infinite',
135 '6::flags' => 'anononly',
136 ),
137 ),
138 array(
139 'text' => 'Sysop changed block settings for Logtestuser with an expiry time of'
140 . ' indefinite (anonymous users only)',
141 'api' => array(
142 'duration' => 'infinite',
143 'flags' => array( 'anononly' ),
144 ),
145 ),
146 ),
147
148 // Old log
149 array(
150 array(
151 'type' => 'block',
152 'action' => 'reblock',
153 'comment' => 'Block comment',
154 'user' => 0,
155 'user_text' => 'Sysop',
156 'namespace' => NS_USER,
157 'title' => 'Logtestuser',
158 'params' => array(
159 'infinite',
160 'anononly',
161 ),
162 ),
163 array(
164 'legacy' => true,
165 'text' => 'Sysop changed block settings for Logtestuser with an expiry time of'
166 . ' indefinite (anonymous users only)',
167 'api' => array(
168 'duration' => 'infinite',
169 'flags' => array( 'anononly' ),
170 ),
171 ),
172 ),
173
174 // Older log without flag
175 array(
176 array(
177 'type' => 'block',
178 'action' => 'reblock',
179 'comment' => 'Block comment',
180 'user' => 0,
181 'user_text' => 'Sysop',
182 'namespace' => NS_USER,
183 'title' => 'Logtestuser',
184 'params' => array(
185 'infinite',
186 )
187 ),
188 array(
189 'legacy' => true,
190 'text' => 'Sysop changed block settings for Logtestuser with an expiry time of indefinite',
191 'api' => array(
192 'duration' => 'infinite',
193 'flags' => array(),
194 ),
195 ),
196 ),
197 );
198 }
199
200 /**
201 * @dataProvider provideReblockLogDatabaseRows
202 */
203 public function testReblockLogDatabaseRows( $row, $extra ) {
204 $this->doTestLogFormatter( $row, $extra );
205 }
206
207 /**
208 * Provide different rows from the logging table to test
209 * for backward compatibility.
210 * Do not change the existing data, just add a new database row
211 */
212 public static function provideUnblockLogDatabaseRows() {
213 return array(
214 // Current log format
215 array(
216 array(
217 'type' => 'block',
218 'action' => 'unblock',
219 'comment' => 'Block comment',
220 'user' => 0,
221 'user_text' => 'Sysop',
222 'namespace' => NS_USER,
223 'title' => 'Logtestuser',
224 'params' => array(),
225 ),
226 array(
227 'text' => 'Sysop unblocked Logtestuser',
228 'api' => array(),
229 ),
230 ),
231 );
232 }
233
234 /**
235 * @dataProvider provideUnblockLogDatabaseRows
236 */
237 public function testUnblockLogDatabaseRows( $row, $extra ) {
238 $this->doTestLogFormatter( $row, $extra );
239 }
240
241 /**
242 * Provide different rows from the logging table to test
243 * for backward compatibility.
244 * Do not change the existing data, just add a new database row
245 */
246 public static function provideSuppressBlockLogDatabaseRows() {
247 return array(
248 // Current log format
249 array(
250 array(
251 'type' => 'suppress',
252 'action' => 'block',
253 'comment' => 'Block comment',
254 'user' => 0,
255 'user_text' => 'Sysop',
256 'namespace' => NS_USER,
257 'title' => 'Logtestuser',
258 'params' => array(
259 '5::duration' => 'infinite',
260 '6::flags' => 'anononly',
261 ),
262 ),
263 array(
264 'text' => 'Sysop blocked Logtestuser with an expiry time of indefinite (anonymous users only)',
265 'api' => array(
266 'duration' => 'infinite',
267 'flags' => array( 'anononly' ),
268 ),
269 ),
270 ),
271
272 // legacy log
273 array(
274 array(
275 'type' => 'suppress',
276 'action' => 'block',
277 'comment' => 'Block comment',
278 'user' => 0,
279 'user_text' => 'Sysop',
280 'namespace' => NS_USER,
281 'title' => 'Logtestuser',
282 'params' => array(
283 'infinite',
284 'anononly',
285 ),
286 ),
287 array(
288 'legacy' => true,
289 'text' => 'Sysop blocked Logtestuser with an expiry time of indefinite (anonymous users only)',
290 'api' => array(
291 'duration' => 'infinite',
292 'flags' => array( 'anononly' ),
293 ),
294 ),
295 ),
296 );
297 }
298
299 /**
300 * @dataProvider provideSuppressBlockLogDatabaseRows
301 */
302 public function testSuppressBlockLogDatabaseRows( $row, $extra ) {
303 $this->doTestLogFormatter( $row, $extra );
304 }
305
306 /**
307 * Provide different rows from the logging table to test
308 * for backward compatibility.
309 * Do not change the existing data, just add a new database row
310 */
311 public static function provideSuppressReblockLogDatabaseRows() {
312 return array(
313 // Current log format
314 array(
315 array(
316 'type' => 'suppress',
317 'action' => 'reblock',
318 'comment' => 'Block comment',
319 'user' => 0,
320 'user_text' => 'Sysop',
321 'namespace' => NS_USER,
322 'title' => 'Logtestuser',
323 'params' => array(
324 '5::duration' => 'infinite',
325 '6::flags' => 'anononly',
326 ),
327 ),
328 array(
329 'text' => 'Sysop changed block settings for Logtestuser with an expiry time of'
330 . ' indefinite (anonymous users only)',
331 'api' => array(
332 'duration' => 'infinite',
333 'flags' => array( 'anononly' ),
334 ),
335 ),
336 ),
337
338 // Legacy format
339 array(
340 array(
341 'type' => 'suppress',
342 'action' => 'reblock',
343 'comment' => 'Block comment',
344 'user' => 0,
345 'user_text' => 'Sysop',
346 'namespace' => NS_USER,
347 'title' => 'Logtestuser',
348 'params' => array(
349 'infinite',
350 'anononly',
351 ),
352 ),
353 array(
354 'legacy' => true,
355 'text' => 'Sysop changed block settings for Logtestuser with an expiry time of'
356 . ' indefinite (anonymous users only)',
357 'api' => array(
358 'duration' => 'infinite',
359 'flags' => array( 'anononly' ),
360 ),
361 ),
362 ),
363 );
364 }
365
366 /**
367 * @dataProvider provideSuppressReblockLogDatabaseRows
368 */
369 public function testSuppressReblockLogDatabaseRows( $row, $extra ) {
370 $this->doTestLogFormatter( $row, $extra );
371 }
372 }