Merge "Drop cache interwiki"
[mediawiki.git] / tests / phpunit / includes / logging / DeleteLogFormatterTest.php
blob81bdf1379db34375942cbee9ed09a09aaddfeb4a
1 <?php
3 /**
4 * @covers \DeleteLogFormatter
5 */
6 class DeleteLogFormatterTest extends LogFormatterTestCase {
8 /**
9 * Provide different rows from the logging table to test
10 * for backward compatibility.
11 * Do not change the existing data, just add a new database row
13 public static function provideDeleteLogDatabaseRows() {
14 return [
15 // Current format
18 'type' => 'delete',
19 'action' => 'delete',
20 'comment' => 'delete comment',
21 'namespace' => NS_MAIN,
22 'title' => 'Page',
23 'params' => [],
26 'text' => 'User deleted page Page',
27 'api' => [],
31 // Legacy format
34 'type' => 'delete',
35 'action' => 'delete',
36 'comment' => 'delete comment',
37 'namespace' => NS_MAIN,
38 'title' => 'Page',
39 'params' => [],
42 'legacy' => true,
43 'text' => 'User deleted page Page',
44 'api' => [],
50 /**
51 * @dataProvider provideDeleteLogDatabaseRows
53 public function testDeleteLogDatabaseRows( $row, $extra ) {
54 $this->doTestLogFormatter( $row, $extra );
57 /**
58 * Provide different rows from the logging table to test
59 * for backward compatibility.
60 * Do not change the existing data, just add a new database row
62 public static function provideRestoreLogDatabaseRows() {
63 return [
64 // Current format
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,
80 'text' => 'User undeleted page Page (2 revisions and 1 file)',
81 'api' => [
82 'count' => [
83 'revisions' => 2,
84 'files' => 1,
90 // Legacy format without counts
93 'type' => 'delete',
94 'action' => 'restore',
95 'comment' => 'delete comment',
96 'namespace' => NS_MAIN,
97 'title' => 'Page',
98 'params' => [],
101 'text' => 'User undeleted page Page',
102 'api' => [],
106 // Legacy format
109 'type' => 'delete',
110 'action' => 'restore',
111 'comment' => 'delete comment',
112 'namespace' => NS_MAIN,
113 'title' => 'Page',
114 'params' => [],
117 'legacy' => true,
118 'text' => 'User undeleted page Page',
119 'api' => [],
126 * @dataProvider provideRestoreLogDatabaseRows
128 public function testRestoreLogDatabaseRows( $row, $extra ) {
129 $this->doTestLogFormatter( $row, $extra );
133 * Provide different rows from the logging table to test
134 * for backward compatibility.
135 * Do not change the existing data, just add a new database row
137 public static function provideRevisionLogDatabaseRows() {
138 return [
139 // Current format
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',
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,
167 'new' => [
168 'bitmask' => 2,
169 'content' => false,
170 'comment' => true,
171 'user' => false,
172 'restricted' => false,
178 // Legacy format
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',
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,
207 'new' => [
208 'bitmask' => 2,
209 'content' => false,
210 'comment' => true,
211 'user' => false,
212 'restricted' => false,
217 // Legacy format pre-T20361, the changes part of the comment
220 'type' => 'delete',
221 'action' => 'revision',
222 'comment' => 'edit summary hidden and content unhidden: delete comment',
223 'namespace' => NS_MAIN,
224 'title' => 'Page',
225 'params' => [
226 'archive',
227 '1,3,4',
231 'legacy' => true,
232 'text' => 'User changed visibility of revisions on page Page',
233 'api' => [
234 'type' => 'archive',
235 'ids' => [ '1', '3', '4' ],
243 * @dataProvider provideRevisionLogDatabaseRows
245 public function testRevisionLogDatabaseRows( $row, $extra ) {
246 $this->doTestLogFormatter( $row, $extra );
250 * Provide different rows from the logging table to test
251 * for backward compatibility.
252 * Do not change the existing data, just add a new database row
254 public static function provideEventLogDatabaseRows() {
255 return [
256 // Current format
259 'type' => 'delete',
260 'action' => 'event',
261 'comment' => 'delete comment',
262 'namespace' => NS_MAIN,
263 'title' => 'Page',
264 'params' => [
265 '4::ids' => [ '1', '3', '4' ],
266 '5::ofield' => '1',
267 '6::nfield' => '2',
271 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
272 . 'and content unhidden',
273 'api' => [
274 'type' => 'logging',
275 'ids' => [ '1', '3', '4' ],
276 'old' => [
277 'bitmask' => 1,
278 'content' => true,
279 'comment' => false,
280 'user' => false,
281 'restricted' => false,
283 'new' => [
284 'bitmask' => 2,
285 'content' => false,
286 'comment' => true,
287 'user' => false,
288 'restricted' => false,
294 // Legacy format
297 'type' => 'delete',
298 'action' => 'event',
299 'comment' => 'delete comment',
300 'namespace' => NS_MAIN,
301 'title' => 'Page',
302 'params' => [
303 '1,3,4',
304 'ofield=1',
305 'nfield=2',
309 'legacy' => true,
310 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
311 . 'and content unhidden',
312 'api' => [
313 'type' => 'logging',
314 'ids' => [ '1', '3', '4' ],
315 'old' => [
316 'bitmask' => 1,
317 'content' => true,
318 'comment' => false,
319 'user' => false,
320 'restricted' => false,
322 'new' => [
323 'bitmask' => 2,
324 'content' => false,
325 'comment' => true,
326 'user' => false,
327 'restricted' => false,
333 // Legacy format pre-T20361, the changes part of the comment
336 'type' => 'delete',
337 'action' => 'event',
338 'comment' => 'edit summary hidden and content unhidden: delete comment',
339 'namespace' => NS_MAIN,
340 'title' => 'Page',
341 'params' => [
342 '1,3,4',
346 'legacy' => true,
347 'text' => 'User changed visibility of log events on Page',
348 'api' => [
349 'type' => 'logging',
350 'ids' => [ '1', '3', '4' ],
358 * @dataProvider provideEventLogDatabaseRows
360 public function testEventLogDatabaseRows( $row, $extra ) {
361 $this->doTestLogFormatter( $row, $extra );
365 * Provide different rows from the logging table to test
366 * for backward compatibility.
367 * Do not change the existing data, just add a new database row
369 public static function provideSuppressRevisionLogDatabaseRows() {
370 return [
371 // Current format
374 'type' => 'suppress',
375 'action' => 'revision',
376 'comment' => 'Suppress comment',
377 'namespace' => NS_MAIN,
378 'title' => 'Page',
379 'params' => [
380 '4::type' => 'archive',
381 '5::ids' => [ '1', '3', '4' ],
382 '6::ofield' => '1',
383 '7::nfield' => '10',
387 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
388 . 'summary hidden, content unhidden and applied restrictions to administrators',
389 'api' => [
390 'type' => 'archive',
391 'ids' => [ '1', '3', '4' ],
392 'old' => [
393 'bitmask' => 1,
394 'content' => true,
395 'comment' => false,
396 'user' => false,
397 'restricted' => false,
399 'new' => [
400 'bitmask' => 10,
401 'content' => false,
402 'comment' => true,
403 'user' => false,
404 'restricted' => true,
410 // Legacy format
413 'type' => 'suppress',
414 'action' => 'revision',
415 'comment' => 'Suppress comment',
416 'namespace' => NS_MAIN,
417 'title' => 'Page',
418 'params' => [
419 'archive',
420 '1,3,4',
421 'ofield=1',
422 'nfield=10',
426 'legacy' => true,
427 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
428 . 'summary hidden, content unhidden and applied restrictions to administrators',
429 'api' => [
430 'type' => 'archive',
431 'ids' => [ '1', '3', '4' ],
432 'old' => [
433 'bitmask' => 1,
434 'content' => true,
435 'comment' => false,
436 'user' => false,
437 'restricted' => false,
439 'new' => [
440 'bitmask' => 10,
441 'content' => false,
442 'comment' => true,
443 'user' => false,
444 'restricted' => true,
450 // Legacy format pre-T20361, the changes part of the comment
453 'type' => 'suppress',
454 'action' => 'revision',
455 'comment' => 'edit summary hidden, content unhidden and applied restrictions to administrators: '
456 . 'Suppress comment',
457 'namespace' => NS_MAIN,
458 'title' => 'Page',
459 'params' => [
460 'archive',
461 '1,3,4',
465 'legacy' => true,
466 'text' => 'User secretly changed visibility of revisions on page Page',
467 'api' => [
468 'type' => 'archive',
469 'ids' => [ '1', '3', '4' ],
477 * Provide different rows from the logging table to test
478 * for backward compatibility.
479 * Do not change the existing data, just add a new database row
481 public static function provideSuppressRevisionLogDatabaseRowsNonPrivileged() {
482 return [
483 // Current format
486 'type' => 'suppress',
487 'action' => 'revision',
488 'comment' => 'Suppress comment',
489 'namespace' => NS_MAIN,
490 'title' => 'Page',
491 'params' => [
492 '4::type' => 'archive',
493 '5::ids' => [ '1', '3', '4' ],
494 '6::ofield' => '1',
495 '7::nfield' => '10',
499 'text' => '(username removed) (log details removed)',
500 'api' => [
501 'type' => 'archive',
502 'ids' => [ '1', '3', '4' ],
503 'old' => [
504 'bitmask' => 1,
505 'content' => true,
506 'comment' => false,
507 'user' => false,
508 'restricted' => false,
510 'new' => [
511 'bitmask' => 10,
512 'content' => false,
513 'comment' => true,
514 'user' => false,
515 'restricted' => true,
521 // Legacy format
524 'type' => 'suppress',
525 'action' => 'revision',
526 'comment' => 'Suppress comment',
527 'namespace' => NS_MAIN,
528 'title' => 'Page',
529 'params' => [
530 'archive',
531 '1,3,4',
532 'ofield=1',
533 'nfield=10',
537 'legacy' => true,
538 'text' => '(username removed) (log details removed)',
539 'api' => [
540 'type' => 'archive',
541 'ids' => [ '1', '3', '4' ],
542 'old' => [
543 'bitmask' => 1,
544 'content' => true,
545 'comment' => false,
546 'user' => false,
547 'restricted' => false,
549 'new' => [
550 'bitmask' => 10,
551 'content' => false,
552 'comment' => true,
553 'user' => false,
554 'restricted' => true,
560 // Legacy format pre-T20361, the changes part of the comment
563 'type' => 'suppress',
564 'action' => 'revision',
565 'comment' => 'Suppress comment',
566 'namespace' => NS_MAIN,
567 'title' => 'Page',
568 'params' => [
569 'archive',
570 '1,3,4',
574 'legacy' => true,
575 'text' => '(username removed) (log details removed)',
576 'api' => [
577 'type' => 'archive',
578 'ids' => [ '1', '3', '4' ],
586 * @dataProvider provideSuppressRevisionLogDatabaseRowsNonPrivileged
588 public function testSuppressRevisionLogDatabaseRowsNonPrivileged( $row, $extra ) {
589 $this->doTestLogFormatter( $row, $extra );
593 * Provide different rows from the logging table to test
594 * for backward compatibility.
595 * Do not change the existing data, just add a new database row
597 public static function provideSuppressEventLogDatabaseRows() {
598 return [
599 // Current format
602 'type' => 'suppress',
603 'action' => 'event',
604 'comment' => 'Suppress comment',
605 'namespace' => NS_MAIN,
606 'title' => 'Page',
607 'params' => [
608 '4::ids' => [ '1', '3', '4' ],
609 '5::ofield' => '1',
610 '6::nfield' => '10',
614 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
615 . 'summary hidden, content unhidden and applied restrictions to administrators',
616 'api' => [
617 'type' => 'logging',
618 'ids' => [ '1', '3', '4' ],
619 'old' => [
620 'bitmask' => 1,
621 'content' => true,
622 'comment' => false,
623 'user' => false,
624 'restricted' => false,
626 'new' => [
627 'bitmask' => 10,
628 'content' => false,
629 'comment' => true,
630 'user' => false,
631 'restricted' => true,
637 // Legacy formats
640 'type' => 'suppress',
641 'action' => 'event',
642 'comment' => 'Suppress comment',
643 'namespace' => NS_MAIN,
644 'title' => 'Page',
645 'params' => [
646 '1,3,4',
647 'ofield=1',
648 'nfield=10',
652 'legacy' => true,
653 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
654 . 'summary hidden, content unhidden and applied restrictions to administrators',
655 'api' => [
656 'type' => 'logging',
657 'ids' => [ '1', '3', '4' ],
658 'old' => [
659 'bitmask' => 1,
660 'content' => true,
661 'comment' => false,
662 'user' => false,
663 'restricted' => false,
665 'new' => [
666 'bitmask' => 10,
667 'content' => false,
668 'comment' => true,
669 'user' => false,
670 'restricted' => true,
676 // Legacy format pre-T20361, the changes part of the comment
679 'type' => 'delete',
680 'action' => 'revision',
681 'comment' => 'Old rows might lack ofield/nfield (T224815)',
682 'namespace' => NS_MAIN,
683 'title' => 'Page',
684 'params' => [
685 'oldid',
686 '1234',
690 'legacy' => true,
691 'text' => 'User changed visibility of revisions on page Page',
692 'api' => [
693 'type' => 'oldid',
694 'ids' => [ '1234' ],
702 * Provide different rows from the logging table to test
703 * for backward compatibility.
704 * Do not change the existing data, just add a new database row
706 public static function provideSuppressEventLogDatabaseRowsNonPrivileged() {
707 return [
708 // Current format
711 'type' => 'suppress',
712 'action' => 'event',
713 'comment' => 'Suppress comment',
714 'namespace' => NS_MAIN,
715 'title' => 'Page',
716 'params' => [
717 '4::ids' => [ '1', '3', '4' ],
718 '5::ofield' => '1',
719 '6::nfield' => '10',
723 'text' => '(username removed) (log details removed)',
724 'api' => [
725 'type' => 'logging',
726 'ids' => [ '1', '3', '4' ],
727 'old' => [
728 'bitmask' => 1,
729 'content' => true,
730 'comment' => false,
731 'user' => false,
732 'restricted' => false,
734 'new' => [
735 'bitmask' => 10,
736 'content' => false,
737 'comment' => true,
738 'user' => false,
739 'restricted' => true,
745 // Legacy format
748 'type' => 'suppress',
749 'action' => 'event',
750 'comment' => 'Suppress comment',
751 'namespace' => NS_MAIN,
752 'title' => 'Page',
753 'params' => [
754 '1,3,4',
755 'ofield=1',
756 'nfield=10',
760 'legacy' => true,
761 'text' => '(username removed) (log details removed)',
762 'api' => [
763 'type' => 'logging',
764 'ids' => [ '1', '3', '4' ],
765 'old' => [
766 'bitmask' => 1,
767 'content' => true,
768 'comment' => false,
769 'user' => false,
770 'restricted' => false,
772 'new' => [
773 'bitmask' => 10,
774 'content' => false,
775 'comment' => true,
776 'user' => false,
777 'restricted' => true,
783 // Legacy format pre-T20361, the changes part of the comment
786 'type' => 'suppress',
787 'action' => 'event',
788 'comment' => 'Suppress comment',
789 'namespace' => NS_MAIN,
790 'title' => 'Page',
791 'params' => [
792 '1,3,4',
796 'legacy' => true,
797 'text' => '(username removed) (log details removed)',
798 'api' => [
799 'type' => 'logging',
800 'ids' => [ '1', '3', '4' ],
808 * @dataProvider provideSuppressEventLogDatabaseRowsNonPrivileged
810 public function testSuppressEventLogDatabaseRowsNonPrivileged( $row, $extra ) {
811 $this->doTestLogFormatter( $row, $extra );
815 * Provide different rows from the logging table to test
816 * for backward compatibility.
817 * Do not change the existing data, just add a new database row
819 public static function provideSuppressDeleteLogDatabaseRows() {
820 return [
821 // Current format
824 'type' => 'suppress',
825 'action' => 'delete',
826 'comment' => 'delete comment',
827 'namespace' => NS_MAIN,
828 'title' => 'Page',
829 'params' => [],
832 'text' => 'User suppressed page Page',
833 'api' => [],
837 // Legacy format
840 'type' => 'suppress',
841 'action' => 'delete',
842 'comment' => 'delete comment',
843 'namespace' => NS_MAIN,
844 'title' => 'Page',
845 'params' => [],
848 'legacy' => true,
849 'text' => 'User suppressed page Page',
850 'api' => [],
857 * @dataProvider provideSuppressRevisionLogDatabaseRows
858 * @dataProvider provideSuppressEventLogDatabaseRows
859 * @dataProvider provideSuppressDeleteLogDatabaseRows
861 public function testSuppressLogDatabaseRows( $row, $extra ) {
862 $this->setGroupPermissions(
864 'oversight' => [
865 'viewsuppressed' => true,
866 'suppressionlog' => true,
870 $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] );
874 * Provide different rows from the logging table to test
875 * for backward compatibility.
876 * Do not change the existing data, just add a new database row
878 public static function provideSuppressDeleteLogDatabaseRowsNonPrivileged() {
879 return [
880 // Current format
883 'type' => 'suppress',
884 'action' => 'delete',
885 'comment' => 'delete comment',
886 'namespace' => NS_MAIN,
887 'title' => 'Page',
888 'params' => [],
891 'text' => '(username removed) (log details removed)',
892 'api' => [],
896 // Legacy format
899 'type' => 'suppress',
900 'action' => 'delete',
901 'comment' => 'delete comment',
902 'namespace' => NS_MAIN,
903 'title' => 'Page',
904 'params' => [],
907 'legacy' => true,
908 'text' => '(username removed) (log details removed)',
909 'api' => [],
916 * @dataProvider provideSuppressDeleteLogDatabaseRowsNonPrivileged
918 public function testSuppressDeleteLogDatabaseRowsNonPrivileged( $row, $extra ) {
919 $this->doTestLogFormatter( $row, $extra );