Import: Handle uploads with sha1 starting with 0 properly
[mediawiki.git] / tests / phpunit / includes / logging / DeleteLogFormatterTest.php
blob28e7efaf8fe772c208b0e70139e0ad9140c2cc94
1 <?php
3 class DeleteLogFormatterTest extends LogFormatterTestCase {
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 provideDeleteLogDatabaseRows() {
11 return array(
12 // Current format
13 array(
14 array(
15 'type' => 'delete',
16 'action' => 'delete',
17 'comment' => 'delete comment',
18 'namespace' => NS_MAIN,
19 'title' => 'Page',
20 'params' => array(),
22 array(
23 'text' => 'User deleted page Page',
24 'api' => array(),
28 // Legacy format
29 array(
30 array(
31 'type' => 'delete',
32 'action' => 'delete',
33 'comment' => 'delete comment',
34 'namespace' => NS_MAIN,
35 'title' => 'Page',
36 'params' => array(),
38 array(
39 'legacy' => true,
40 'text' => 'User deleted page Page',
41 'api' => array(),
47 /**
48 * @dataProvider provideDeleteLogDatabaseRows
50 public function testDeleteLogDatabaseRows( $row, $extra ) {
51 $this->doTestLogFormatter( $row, $extra );
54 /**
55 * Provide different rows from the logging table to test
56 * for backward compatibility.
57 * Do not change the existing data, just add a new database row
59 public static function provideRestoreLogDatabaseRows() {
60 return array(
61 // Current format
62 array(
63 array(
64 'type' => 'delete',
65 'action' => 'restore',
66 'comment' => 'delete comment',
67 'namespace' => NS_MAIN,
68 'title' => 'Page',
69 'params' => array(),
71 array(
72 'text' => 'User restored page Page',
73 'api' => array(),
77 // Legacy format
78 array(
79 array(
80 'type' => 'delete',
81 'action' => 'restore',
82 'comment' => 'delete comment',
83 'namespace' => NS_MAIN,
84 'title' => 'Page',
85 'params' => array(),
87 array(
88 'legacy' => true,
89 'text' => 'User restored page Page',
90 'api' => array(),
96 /**
97 * @dataProvider provideRestoreLogDatabaseRows
99 public function testRestoreLogDatabaseRows( $row, $extra ) {
100 $this->doTestLogFormatter( $row, $extra );
104 * Provide different rows from the logging table to test
105 * for backward compatibility.
106 * Do not change the existing data, just add a new database row
108 public static function provideRevisionLogDatabaseRows() {
109 return array(
110 // Current format
111 array(
112 array(
113 'type' => 'delete',
114 'action' => 'revision',
115 'comment' => 'delete comment',
116 'namespace' => NS_MAIN,
117 'title' => 'Page',
118 'params' => array(
119 '4::type' => 'archive',
120 '5::ids' => array( '1', '3', '4' ),
121 '6::ofield' => '1',
122 '7::nfield' => '2',
125 array(
126 'text' => 'User changed visibility of 3 revisions on page Page: edit summary '
127 . 'hidden and content unhidden',
128 'api' => array(
129 'type' => 'archive',
130 'ids' => array( '1', '3', '4' ),
131 'old' => array(
132 'bitmask' => 1,
133 'content' => true,
134 'comment' => false,
135 'user' => false,
136 'restricted' => false,
138 'new' => array(
139 'bitmask' => 2,
140 'content' => false,
141 'comment' => true,
142 'user' => false,
143 'restricted' => false,
149 // Legacy format
150 array(
151 array(
152 'type' => 'delete',
153 'action' => 'revision',
154 'comment' => 'delete comment',
155 'namespace' => NS_MAIN,
156 'title' => 'Page',
157 'params' => array(
158 'archive',
159 '1,3,4',
160 'ofield=1',
161 'nfield=2',
164 array(
165 'legacy' => true,
166 'text' => 'User changed visibility of 3 revisions on page Page: edit summary '
167 . 'hidden and content unhidden',
168 'api' => array(
169 'type' => 'archive',
170 'ids' => array( '1', '3', '4' ),
171 'old' => array(
172 'bitmask' => 1,
173 'content' => true,
174 'comment' => false,
175 'user' => false,
176 'restricted' => false,
178 'new' => array(
179 'bitmask' => 2,
180 'content' => false,
181 'comment' => true,
182 'user' => false,
183 'restricted' => false,
192 * @dataProvider provideRevisionLogDatabaseRows
194 public function testRevisionLogDatabaseRows( $row, $extra ) {
195 $this->doTestLogFormatter( $row, $extra );
199 * Provide different rows from the logging table to test
200 * for backward compatibility.
201 * Do not change the existing data, just add a new database row
203 public static function provideEventLogDatabaseRows() {
204 return array(
205 // Current format
206 array(
207 array(
208 'type' => 'delete',
209 'action' => 'event',
210 'comment' => 'delete comment',
211 'namespace' => NS_MAIN,
212 'title' => 'Page',
213 'params' => array(
214 '4::ids' => array( '1', '3', '4' ),
215 '5::ofield' => '1',
216 '6::nfield' => '2',
219 array(
220 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
221 . 'and content unhidden',
222 'api' => array(
223 'type' => 'logging',
224 'ids' => array( '1', '3', '4' ),
225 'old' => array(
226 'bitmask' => 1,
227 'content' => true,
228 'comment' => false,
229 'user' => false,
230 'restricted' => false,
232 'new' => array(
233 'bitmask' => 2,
234 'content' => false,
235 'comment' => true,
236 'user' => false,
237 'restricted' => false,
243 // Legacy format
244 array(
245 array(
246 'type' => 'delete',
247 'action' => 'event',
248 'comment' => 'delete comment',
249 'namespace' => NS_MAIN,
250 'title' => 'Page',
251 'params' => array(
252 '1,3,4',
253 'ofield=1',
254 'nfield=2',
257 array(
258 'legacy' => true,
259 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
260 . 'and content unhidden',
261 'api' => array(
262 'type' => 'logging',
263 'ids' => array( '1', '3', '4' ),
264 'old' => array(
265 'bitmask' => 1,
266 'content' => true,
267 'comment' => false,
268 'user' => false,
269 'restricted' => false,
271 'new' => array(
272 'bitmask' => 2,
273 'content' => false,
274 'comment' => true,
275 'user' => false,
276 'restricted' => false,
285 * @dataProvider provideEventLogDatabaseRows
287 public function testEventLogDatabaseRows( $row, $extra ) {
288 $this->doTestLogFormatter( $row, $extra );
292 * Provide different rows from the logging table to test
293 * for backward compatibility.
294 * Do not change the existing data, just add a new database row
296 public static function provideSuppressRevisionLogDatabaseRows() {
297 return array(
298 // Current format
299 array(
300 array(
301 'type' => 'suppress',
302 'action' => 'revision',
303 'comment' => 'Suppress comment',
304 'namespace' => NS_MAIN,
305 'title' => 'Page',
306 'params' => array(
307 '4::type' => 'archive',
308 '5::ids' => array( '1', '3', '4' ),
309 '6::ofield' => '1',
310 '7::nfield' => '10',
313 array(
314 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
315 . 'summary hidden, content unhidden and applied restrictions to administrators',
316 'api' => array(
317 'type' => 'archive',
318 'ids' => array( '1', '3', '4' ),
319 'old' => array(
320 'bitmask' => 1,
321 'content' => true,
322 'comment' => false,
323 'user' => false,
324 'restricted' => false,
326 'new' => array(
327 'bitmask' => 10,
328 'content' => false,
329 'comment' => true,
330 'user' => false,
331 'restricted' => true,
337 // Legacy format
338 array(
339 array(
340 'type' => 'suppress',
341 'action' => 'revision',
342 'comment' => 'Suppress comment',
343 'namespace' => NS_MAIN,
344 'title' => 'Page',
345 'params' => array(
346 'archive',
347 '1,3,4',
348 'ofield=1',
349 'nfield=10',
352 array(
353 'legacy' => true,
354 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
355 . 'summary hidden, content unhidden and applied restrictions to administrators',
356 'api' => array(
357 'type' => 'archive',
358 'ids' => array( '1', '3', '4' ),
359 'old' => array(
360 'bitmask' => 1,
361 'content' => true,
362 'comment' => false,
363 'user' => false,
364 'restricted' => false,
366 'new' => array(
367 'bitmask' => 10,
368 'content' => false,
369 'comment' => true,
370 'user' => false,
371 'restricted' => true,
380 * @dataProvider provideSuppressRevisionLogDatabaseRows
382 public function testSuppressRevisionLogDatabaseRows( $row, $extra ) {
383 $this->doTestLogFormatter( $row, $extra );
387 * Provide different rows from the logging table to test
388 * for backward compatibility.
389 * Do not change the existing data, just add a new database row
391 public static function provideSuppressEventLogDatabaseRows() {
392 return array(
393 // Current format
394 array(
395 array(
396 'type' => 'suppress',
397 'action' => 'event',
398 'comment' => 'Suppress comment',
399 'namespace' => NS_MAIN,
400 'title' => 'Page',
401 'params' => array(
402 '4::ids' => array( '1', '3', '4' ),
403 '5::ofield' => '1',
404 '6::nfield' => '10',
407 array(
408 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
409 . 'summary hidden, content unhidden and applied restrictions to administrators',
410 'api' => array(
411 'type' => 'logging',
412 'ids' => array( '1', '3', '4' ),
413 'old' => array(
414 'bitmask' => 1,
415 'content' => true,
416 'comment' => false,
417 'user' => false,
418 'restricted' => false,
420 'new' => array(
421 'bitmask' => 10,
422 'content' => false,
423 'comment' => true,
424 'user' => false,
425 'restricted' => true,
431 // Legacy format
432 array(
433 array(
434 'type' => 'suppress',
435 'action' => 'event',
436 'comment' => 'Suppress comment',
437 'namespace' => NS_MAIN,
438 'title' => 'Page',
439 'params' => array(
440 '1,3,4',
441 'ofield=1',
442 'nfield=10',
445 array(
446 'legacy' => true,
447 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
448 . 'summary hidden, content unhidden and applied restrictions to administrators',
449 'api' => array(
450 'type' => 'logging',
451 'ids' => array( '1', '3', '4' ),
452 'old' => array(
453 'bitmask' => 1,
454 'content' => true,
455 'comment' => false,
456 'user' => false,
457 'restricted' => false,
459 'new' => array(
460 'bitmask' => 10,
461 'content' => false,
462 'comment' => true,
463 'user' => false,
464 'restricted' => true,
473 * @dataProvider provideSuppressEventLogDatabaseRows
475 public function testSuppressEventLogDatabaseRows( $row, $extra ) {
476 $this->doTestLogFormatter( $row, $extra );
480 * Provide different rows from the logging table to test
481 * for backward compatibility.
482 * Do not change the existing data, just add a new database row
484 public static function provideSuppressDeleteLogDatabaseRows() {
485 return array(
486 // Current format
487 array(
488 array(
489 'type' => 'suppress',
490 'action' => 'delete',
491 'comment' => 'delete comment',
492 'namespace' => NS_MAIN,
493 'title' => 'Page',
494 'params' => array(),
496 array(
497 'text' => 'User suppressed page Page',
498 'api' => array(),
502 // Legacy format
503 array(
504 array(
505 'type' => 'suppress',
506 'action' => 'delete',
507 'comment' => 'delete comment',
508 'namespace' => NS_MAIN,
509 'title' => 'Page',
510 'params' => array(),
512 array(
513 'legacy' => true,
514 'text' => 'User suppressed page Page',
515 'api' => array(),
522 * @dataProvider provideSuppressDeleteLogDatabaseRows
524 public function testSuppressDeleteLogDatabaseRows( $row, $extra ) {
525 $this->doTestLogFormatter( $row, $extra );