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