4 * @covers \DeleteLogFormatter
6 class DeleteLogFormatterTest
extends LogFormatterTestCase
{
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() {
20 'comment' => 'delete comment',
21 'namespace' => NS_MAIN
,
26 'text' => 'User deleted page Page',
36 'comment' => 'delete comment',
37 'namespace' => NS_MAIN
,
43 'text' => 'User deleted page Page',
51 * @dataProvider provideDeleteLogDatabaseRows
53 public function testDeleteLogDatabaseRows( $row, $extra ) {
54 $this->doTestLogFormatter( $row, $extra );
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() {
68 'action' => 'restore',
69 'comment' => 'delete comment',
70 'namespace' => NS_MAIN
,
80 'text' => 'User undeleted page Page (2 revisions and 1 file)',
90 // Legacy format without counts
94 'action' => 'restore',
95 'comment' => 'delete comment',
96 'namespace' => NS_MAIN
,
101 'text' => 'User undeleted page Page',
110 'action' => 'restore',
111 'comment' => 'delete comment',
112 'namespace' => NS_MAIN
,
118 'text' => 'User undeleted page Page',
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() {
143 'action' => 'revision',
144 'comment' => 'delete comment',
145 'namespace' => NS_MAIN
,
148 '4::type' => 'archive',
149 '5::ids' => [ '1', '3', '4' ],
155 'text' => 'User changed visibility of 3 revisions on page Page: edit summary '
156 . 'hidden and content unhidden',
159 'ids' => [ '1', '3', '4' ],
165 'restricted' => false,
172 'restricted' => false,
182 'action' => 'revision',
183 'comment' => 'delete comment',
184 'namespace' => NS_MAIN
,
195 'text' => 'User changed visibility of 3 revisions on page Page: edit summary '
196 . 'hidden and content unhidden',
199 'ids' => [ '1', '3', '4' ],
205 'restricted' => false,
212 'restricted' => false,
217 // Legacy format pre-T20361, the changes part of the comment
221 'action' => 'revision',
222 'comment' => 'edit summary hidden and content unhidden: delete comment',
223 'namespace' => NS_MAIN
,
232 'text' => 'User changed visibility of revisions on page Page',
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() {
261 'comment' => 'delete comment',
262 'namespace' => NS_MAIN
,
265 '4::ids' => [ '1', '3', '4' ],
271 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
272 . 'and content unhidden',
275 'ids' => [ '1', '3', '4' ],
281 'restricted' => false,
288 'restricted' => false,
299 'comment' => 'delete comment',
300 'namespace' => NS_MAIN
,
310 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
311 . 'and content unhidden',
314 'ids' => [ '1', '3', '4' ],
320 'restricted' => false,
327 'restricted' => false,
333 // Legacy format pre-T20361, the changes part of the comment
338 'comment' => 'edit summary hidden and content unhidden: delete comment',
339 'namespace' => NS_MAIN
,
347 'text' => 'User changed visibility of log events on Page',
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() {
374 'type' => 'suppress',
375 'action' => 'revision',
376 'comment' => 'Suppress comment',
377 'namespace' => NS_MAIN
,
380 '4::type' => 'archive',
381 '5::ids' => [ '1', '3', '4' ],
387 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
388 . 'summary hidden, content unhidden and applied restrictions to administrators',
391 'ids' => [ '1', '3', '4' ],
397 'restricted' => false,
404 'restricted' => true,
413 'type' => 'suppress',
414 'action' => 'revision',
415 'comment' => 'Suppress comment',
416 'namespace' => NS_MAIN
,
427 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
428 . 'summary hidden, content unhidden and applied restrictions to administrators',
431 'ids' => [ '1', '3', '4' ],
437 'restricted' => 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
,
466 'text' => 'User secretly changed visibility of revisions on page Page',
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() {
486 'type' => 'suppress',
487 'action' => 'revision',
488 'comment' => 'Suppress comment',
489 'namespace' => NS_MAIN
,
492 '4::type' => 'archive',
493 '5::ids' => [ '1', '3', '4' ],
499 'text' => '(username removed) (log details removed)',
502 'ids' => [ '1', '3', '4' ],
508 'restricted' => false,
515 'restricted' => true,
524 'type' => 'suppress',
525 'action' => 'revision',
526 'comment' => 'Suppress comment',
527 'namespace' => NS_MAIN
,
538 'text' => '(username removed) (log details removed)',
541 'ids' => [ '1', '3', '4' ],
547 'restricted' => 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
,
575 'text' => '(username removed) (log details removed)',
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() {
602 'type' => 'suppress',
604 'comment' => 'Suppress comment',
605 'namespace' => NS_MAIN
,
608 '4::ids' => [ '1', '3', '4' ],
614 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
615 . 'summary hidden, content unhidden and applied restrictions to administrators',
618 'ids' => [ '1', '3', '4' ],
624 'restricted' => false,
631 'restricted' => true,
640 'type' => 'suppress',
642 'comment' => 'Suppress comment',
643 'namespace' => NS_MAIN
,
653 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
654 . 'summary hidden, content unhidden and applied restrictions to administrators',
657 'ids' => [ '1', '3', '4' ],
663 'restricted' => false,
670 'restricted' => true,
676 // Legacy format pre-T20361, the changes part of the comment
680 'action' => 'revision',
681 'comment' => 'Old rows might lack ofield/nfield (T224815)',
682 'namespace' => NS_MAIN
,
691 'text' => 'User changed visibility of revisions on page Page',
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() {
711 'type' => 'suppress',
713 'comment' => 'Suppress comment',
714 'namespace' => NS_MAIN
,
717 '4::ids' => [ '1', '3', '4' ],
723 'text' => '(username removed) (log details removed)',
726 'ids' => [ '1', '3', '4' ],
732 'restricted' => false,
739 'restricted' => true,
748 'type' => 'suppress',
750 'comment' => 'Suppress comment',
751 'namespace' => NS_MAIN
,
761 'text' => '(username removed) (log details removed)',
764 'ids' => [ '1', '3', '4' ],
770 'restricted' => false,
777 'restricted' => true,
783 // Legacy format pre-T20361, the changes part of the comment
786 'type' => 'suppress',
788 'comment' => 'Suppress comment',
789 'namespace' => NS_MAIN
,
797 'text' => '(username removed) (log details removed)',
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() {
824 'type' => 'suppress',
825 'action' => 'delete',
826 'comment' => 'delete comment',
827 'namespace' => NS_MAIN
,
832 'text' => 'User suppressed page Page',
840 'type' => 'suppress',
841 'action' => 'delete',
842 'comment' => 'delete comment',
843 'namespace' => NS_MAIN
,
849 'text' => 'User suppressed page Page',
857 * @dataProvider provideSuppressRevisionLogDatabaseRows
858 * @dataProvider provideSuppressEventLogDatabaseRows
859 * @dataProvider provideSuppressDeleteLogDatabaseRows
861 public function testSuppressLogDatabaseRows( $row, $extra ) {
862 $this->setGroupPermissions(
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() {
883 'type' => 'suppress',
884 'action' => 'delete',
885 'comment' => 'delete comment',
886 'namespace' => NS_MAIN
,
891 'text' => '(username removed) (log details removed)',
899 'type' => 'suppress',
900 'action' => 'delete',
901 'comment' => 'delete comment',
902 'namespace' => NS_MAIN
,
908 'text' => '(username removed) (log details removed)',
916 * @dataProvider provideSuppressDeleteLogDatabaseRowsNonPrivileged
918 public function testSuppressDeleteLogDatabaseRowsNonPrivileged( $row, $extra ) {
919 $this->doTestLogFormatter( $row, $extra );