MediaWiki REL1_30
DeleteLogFormatterTest.php
Go to the documentation of this file.
1<?php
2
4
10 public static function provideDeleteLogDatabaseRows() {
11 return [
12 // Current format
13 [
14 [
15 'type' => 'delete',
16 'action' => 'delete',
17 'comment' => 'delete comment',
18 'namespace' => NS_MAIN,
19 'title' => 'Page',
20 'params' => [],
21 ],
22 [
23 'text' => 'User deleted page Page',
24 'api' => [],
25 ],
26 ],
27
28 // Legacy format
29 [
30 [
31 'type' => 'delete',
32 'action' => 'delete',
33 'comment' => 'delete comment',
34 'namespace' => NS_MAIN,
35 'title' => 'Page',
36 'params' => [],
37 ],
38 [
39 'legacy' => true,
40 'text' => 'User deleted page Page',
41 'api' => [],
42 ],
43 ],
44 ];
45 }
46
50 public function testDeleteLogDatabaseRows( $row, $extra ) {
51 $this->doTestLogFormatter( $row, $extra );
52 }
53
59 public static function provideRestoreLogDatabaseRows() {
60 return [
61 // Current format
62 [
63 [
64 'type' => 'delete',
65 'action' => 'restore',
66 'comment' => 'delete comment',
67 'namespace' => NS_MAIN,
68 'title' => 'Page',
69 'params' => [
70 ':assoc:count' => [
71 'revisions' => 2,
72 'files' => 1,
73 ],
74 ],
75 ],
76 [
77 'text' => 'User restored page Page (2 revisions and 1 file)',
78 'api' => [
79 'count' => [
80 'revisions' => 2,
81 'files' => 1,
82 ],
83 ],
84 ],
85 ],
86
87 // Legacy format without counts
88 [
89 [
90 'type' => 'delete',
91 'action' => 'restore',
92 'comment' => 'delete comment',
93 'namespace' => NS_MAIN,
94 'title' => 'Page',
95 'params' => [],
96 ],
97 [
98 'text' => 'User restored page Page',
99 'api' => [],
100 ],
101 ],
102
103 // Legacy format
104 [
105 [
106 'type' => 'delete',
107 'action' => 'restore',
108 'comment' => 'delete comment',
109 'namespace' => NS_MAIN,
110 'title' => 'Page',
111 'params' => [],
112 ],
113 [
114 'legacy' => true,
115 'text' => 'User restored page Page',
116 'api' => [],
117 ],
118 ],
119 ];
120 }
121
125 public function testRestoreLogDatabaseRows( $row, $extra ) {
126 $this->doTestLogFormatter( $row, $extra );
127 }
128
134 public static function provideRevisionLogDatabaseRows() {
135 return [
136 // Current format
137 [
138 [
139 'type' => 'delete',
140 'action' => 'revision',
141 'comment' => 'delete comment',
142 'namespace' => NS_MAIN,
143 'title' => 'Page',
144 'params' => [
145 '4::type' => 'archive',
146 '5::ids' => [ '1', '3', '4' ],
147 '6::ofield' => '1',
148 '7::nfield' => '2',
149 ],
150 ],
151 [
152 'text' => 'User changed visibility of 3 revisions on page Page: edit summary '
153 . 'hidden and content unhidden',
154 'api' => [
155 'type' => 'archive',
156 'ids' => [ '1', '3', '4' ],
157 'old' => [
158 'bitmask' => 1,
159 'content' => true,
160 'comment' => false,
161 'user' => false,
162 'restricted' => false,
163 ],
164 'new' => [
165 'bitmask' => 2,
166 'content' => false,
167 'comment' => true,
168 'user' => false,
169 'restricted' => false,
170 ],
171 ],
172 ],
173 ],
174
175 // Legacy format
176 [
177 [
178 'type' => 'delete',
179 'action' => 'revision',
180 'comment' => 'delete comment',
181 'namespace' => NS_MAIN,
182 'title' => 'Page',
183 'params' => [
184 'archive',
185 '1,3,4',
186 'ofield=1',
187 'nfield=2',
188 ],
189 ],
190 [
191 'legacy' => true,
192 'text' => 'User changed visibility of 3 revisions on page Page: edit summary '
193 . 'hidden and content unhidden',
194 'api' => [
195 'type' => 'archive',
196 'ids' => [ '1', '3', '4' ],
197 'old' => [
198 'bitmask' => 1,
199 'content' => true,
200 'comment' => false,
201 'user' => false,
202 'restricted' => false,
203 ],
204 'new' => [
205 'bitmask' => 2,
206 'content' => false,
207 'comment' => true,
208 'user' => false,
209 'restricted' => false,
210 ],
211 ],
212 ],
213 ],
214 ];
215 }
216
220 public function testRevisionLogDatabaseRows( $row, $extra ) {
221 $this->doTestLogFormatter( $row, $extra );
222 }
223
229 public static function provideEventLogDatabaseRows() {
230 return [
231 // Current format
232 [
233 [
234 'type' => 'delete',
235 'action' => 'event',
236 'comment' => 'delete comment',
237 'namespace' => NS_MAIN,
238 'title' => 'Page',
239 'params' => [
240 '4::ids' => [ '1', '3', '4' ],
241 '5::ofield' => '1',
242 '6::nfield' => '2',
243 ],
244 ],
245 [
246 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
247 . 'and content unhidden',
248 'api' => [
249 'type' => 'logging',
250 'ids' => [ '1', '3', '4' ],
251 'old' => [
252 'bitmask' => 1,
253 'content' => true,
254 'comment' => false,
255 'user' => false,
256 'restricted' => false,
257 ],
258 'new' => [
259 'bitmask' => 2,
260 'content' => false,
261 'comment' => true,
262 'user' => false,
263 'restricted' => false,
264 ],
265 ],
266 ],
267 ],
268
269 // Legacy format
270 [
271 [
272 'type' => 'delete',
273 'action' => 'event',
274 'comment' => 'delete comment',
275 'namespace' => NS_MAIN,
276 'title' => 'Page',
277 'params' => [
278 '1,3,4',
279 'ofield=1',
280 'nfield=2',
281 ],
282 ],
283 [
284 'legacy' => true,
285 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
286 . 'and content unhidden',
287 'api' => [
288 'type' => 'logging',
289 'ids' => [ '1', '3', '4' ],
290 'old' => [
291 'bitmask' => 1,
292 'content' => true,
293 'comment' => false,
294 'user' => false,
295 'restricted' => false,
296 ],
297 'new' => [
298 'bitmask' => 2,
299 'content' => false,
300 'comment' => true,
301 'user' => false,
302 'restricted' => false,
303 ],
304 ],
305 ],
306 ],
307 ];
308 }
309
313 public function testEventLogDatabaseRows( $row, $extra ) {
314 $this->doTestLogFormatter( $row, $extra );
315 }
316
322 public static function provideSuppressRevisionLogDatabaseRows() {
323 return [
324 // Current format
325 [
326 [
327 'type' => 'suppress',
328 'action' => 'revision',
329 'comment' => 'Suppress comment',
330 'namespace' => NS_MAIN,
331 'title' => 'Page',
332 'params' => [
333 '4::type' => 'archive',
334 '5::ids' => [ '1', '3', '4' ],
335 '6::ofield' => '1',
336 '7::nfield' => '10',
337 ],
338 ],
339 [
340 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
341 . 'summary hidden, content unhidden and applied restrictions to administrators',
342 'api' => [
343 'type' => 'archive',
344 'ids' => [ '1', '3', '4' ],
345 'old' => [
346 'bitmask' => 1,
347 'content' => true,
348 'comment' => false,
349 'user' => false,
350 'restricted' => false,
351 ],
352 'new' => [
353 'bitmask' => 10,
354 'content' => false,
355 'comment' => true,
356 'user' => false,
357 'restricted' => true,
358 ],
359 ],
360 ],
361 ],
362
363 // Legacy format
364 [
365 [
366 'type' => 'suppress',
367 'action' => 'revision',
368 'comment' => 'Suppress comment',
369 'namespace' => NS_MAIN,
370 'title' => 'Page',
371 'params' => [
372 'archive',
373 '1,3,4',
374 'ofield=1',
375 'nfield=10',
376 ],
377 ],
378 [
379 'legacy' => true,
380 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
381 . 'summary hidden, content unhidden and applied restrictions to administrators',
382 'api' => [
383 'type' => 'archive',
384 'ids' => [ '1', '3', '4' ],
385 'old' => [
386 'bitmask' => 1,
387 'content' => true,
388 'comment' => false,
389 'user' => false,
390 'restricted' => false,
391 ],
392 'new' => [
393 'bitmask' => 10,
394 'content' => false,
395 'comment' => true,
396 'user' => false,
397 'restricted' => true,
398 ],
399 ],
400 ],
401 ],
402 ];
403 }
404
408 public function testSuppressRevisionLogDatabaseRows( $row, $extra ) {
409 $this->doTestLogFormatter( $row, $extra );
410 }
411
417 public static function provideSuppressEventLogDatabaseRows() {
418 return [
419 // Current format
420 [
421 [
422 'type' => 'suppress',
423 'action' => 'event',
424 'comment' => 'Suppress comment',
425 'namespace' => NS_MAIN,
426 'title' => 'Page',
427 'params' => [
428 '4::ids' => [ '1', '3', '4' ],
429 '5::ofield' => '1',
430 '6::nfield' => '10',
431 ],
432 ],
433 [
434 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
435 . 'summary hidden, content unhidden and applied restrictions to administrators',
436 'api' => [
437 'type' => 'logging',
438 'ids' => [ '1', '3', '4' ],
439 'old' => [
440 'bitmask' => 1,
441 'content' => true,
442 'comment' => false,
443 'user' => false,
444 'restricted' => false,
445 ],
446 'new' => [
447 'bitmask' => 10,
448 'content' => false,
449 'comment' => true,
450 'user' => false,
451 'restricted' => true,
452 ],
453 ],
454 ],
455 ],
456
457 // Legacy format
458 [
459 [
460 'type' => 'suppress',
461 'action' => 'event',
462 'comment' => 'Suppress comment',
463 'namespace' => NS_MAIN,
464 'title' => 'Page',
465 'params' => [
466 '1,3,4',
467 'ofield=1',
468 'nfield=10',
469 ],
470 ],
471 [
472 'legacy' => true,
473 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
474 . 'summary hidden, content unhidden and applied restrictions to administrators',
475 'api' => [
476 'type' => 'logging',
477 'ids' => [ '1', '3', '4' ],
478 'old' => [
479 'bitmask' => 1,
480 'content' => true,
481 'comment' => false,
482 'user' => false,
483 'restricted' => false,
484 ],
485 'new' => [
486 'bitmask' => 10,
487 'content' => false,
488 'comment' => true,
489 'user' => false,
490 'restricted' => true,
491 ],
492 ],
493 ],
494 ],
495 ];
496 }
497
501 public function testSuppressEventLogDatabaseRows( $row, $extra ) {
502 $this->doTestLogFormatter( $row, $extra );
503 }
504
510 public static function provideSuppressDeleteLogDatabaseRows() {
511 return [
512 // Current format
513 [
514 [
515 'type' => 'suppress',
516 'action' => 'delete',
517 'comment' => 'delete comment',
518 'namespace' => NS_MAIN,
519 'title' => 'Page',
520 'params' => [],
521 ],
522 [
523 'text' => 'User suppressed page Page',
524 'api' => [],
525 ],
526 ],
527
528 // Legacy format
529 [
530 [
531 'type' => 'suppress',
532 'action' => 'delete',
533 'comment' => 'delete comment',
534 'namespace' => NS_MAIN,
535 'title' => 'Page',
536 'params' => [],
537 ],
538 [
539 'legacy' => true,
540 'text' => 'User suppressed page Page',
541 'api' => [],
542 ],
543 ],
544 ];
545 }
546
550 public function testSuppressDeleteLogDatabaseRows( $row, $extra ) {
551 $this->doTestLogFormatter( $row, $extra );
552 }
553}
testRestoreLogDatabaseRows( $row, $extra)
provideRestoreLogDatabaseRows
static provideRestoreLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testSuppressRevisionLogDatabaseRows( $row, $extra)
provideSuppressRevisionLogDatabaseRows
static provideEventLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
static provideSuppressEventLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
static provideRevisionLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testSuppressDeleteLogDatabaseRows( $row, $extra)
provideSuppressDeleteLogDatabaseRows
testRevisionLogDatabaseRows( $row, $extra)
provideRevisionLogDatabaseRows
static provideSuppressDeleteLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testDeleteLogDatabaseRows( $row, $extra)
provideDeleteLogDatabaseRows
testEventLogDatabaseRows( $row, $extra)
provideEventLogDatabaseRows
static provideDeleteLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testSuppressEventLogDatabaseRows( $row, $extra)
provideSuppressEventLogDatabaseRows
static provideSuppressRevisionLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
doTestLogFormatter( $row, $extra)
const NS_MAIN
Definition Defines.php:65