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 restored 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 restored page Page',
110 'action' => 'restore',
111 'comment' => 'delete comment',
112 'namespace' => NS_MAIN
,
118 'text' => 'User restored 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,
221 * @dataProvider provideRevisionLogDatabaseRows
223 public function testRevisionLogDatabaseRows( $row, $extra ) {
224 $this->doTestLogFormatter( $row, $extra );
228 * Provide different rows from the logging table to test
229 * for backward compatibility.
230 * Do not change the existing data, just add a new database row
232 public static function provideEventLogDatabaseRows() {
239 'comment' => 'delete comment',
240 'namespace' => NS_MAIN
,
243 '4::ids' => [ '1', '3', '4' ],
249 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
250 . 'and content unhidden',
253 'ids' => [ '1', '3', '4' ],
259 'restricted' => false,
266 'restricted' => false,
277 'comment' => 'delete comment',
278 'namespace' => NS_MAIN
,
288 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
289 . 'and content unhidden',
292 'ids' => [ '1', '3', '4' ],
298 'restricted' => false,
305 'restricted' => false,
314 * @dataProvider provideEventLogDatabaseRows
316 public function testEventLogDatabaseRows( $row, $extra ) {
317 $this->doTestLogFormatter( $row, $extra );
321 * Provide different rows from the logging table to test
322 * for backward compatibility.
323 * Do not change the existing data, just add a new database row
325 public static function provideSuppressRevisionLogDatabaseRows() {
330 'type' => 'suppress',
331 'action' => 'revision',
332 'comment' => 'Suppress comment',
333 'namespace' => NS_MAIN
,
336 '4::type' => 'archive',
337 '5::ids' => [ '1', '3', '4' ],
343 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
344 . 'summary hidden, content unhidden and applied restrictions to administrators',
347 'ids' => [ '1', '3', '4' ],
353 'restricted' => false,
360 'restricted' => true,
369 'type' => 'suppress',
370 'action' => 'revision',
371 'comment' => 'Suppress comment',
372 'namespace' => NS_MAIN
,
383 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
384 . 'summary hidden, content unhidden and applied restrictions to administrators',
387 'ids' => [ '1', '3', '4' ],
393 'restricted' => false,
400 'restricted' => true,
409 * @dataProvider provideSuppressRevisionLogDatabaseRows
411 public function testSuppressRevisionLogDatabaseRows( $row, $extra ) {
413 'wgGroupPermissions',
416 'viewsuppressed' => true,
417 'suppressionlog' => true,
421 $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] );
425 * Provide different rows from the logging table to test
426 * for backward compatibility.
427 * Do not change the existing data, just add a new database row
429 public static function provideSuppressRevisionLogDatabaseRowsNonPrivileged() {
434 'type' => 'suppress',
435 'action' => 'revision',
436 'comment' => 'Suppress comment',
437 'namespace' => NS_MAIN
,
440 '4::type' => 'archive',
441 '5::ids' => [ '1', '3', '4' ],
447 'text' => '(username removed) (log details removed)',
450 'ids' => [ '1', '3', '4' ],
456 'restricted' => false,
463 'restricted' => true,
472 'type' => 'suppress',
473 'action' => 'revision',
474 'comment' => 'Suppress comment',
475 'namespace' => NS_MAIN
,
486 'text' => '(username removed) (log details removed)',
489 'ids' => [ '1', '3', '4' ],
495 'restricted' => false,
502 'restricted' => true,
511 * @dataProvider provideSuppressRevisionLogDatabaseRowsNonPrivileged
513 public function testSuppressRevisionLogDatabaseRowsNonPrivileged( $row, $extra ) {
514 $this->user
= $this->getTestUser()->getUser();
515 $this->doTestLogFormatter( $row, $extra );
519 * Provide different rows from the logging table to test
520 * for backward compatibility.
521 * Do not change the existing data, just add a new database row
523 public static function provideSuppressEventLogDatabaseRows() {
528 'type' => 'suppress',
530 'comment' => 'Suppress comment',
531 'namespace' => NS_MAIN
,
534 '4::ids' => [ '1', '3', '4' ],
540 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
541 . 'summary hidden, content unhidden and applied restrictions to administrators',
544 'ids' => [ '1', '3', '4' ],
550 'restricted' => false,
557 'restricted' => true,
566 'type' => 'suppress',
568 'comment' => 'Suppress comment',
569 'namespace' => NS_MAIN
,
579 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
580 . 'summary hidden, content unhidden and applied restrictions to administrators',
583 'ids' => [ '1', '3', '4' ],
589 'restricted' => false,
596 'restricted' => true,
604 'action' => 'revision',
605 'comment' => 'Old rows might lack ofield/nfield (T224815)',
606 'namespace' => NS_MAIN
,
615 'text' => 'User changed visibility of revisions on page Page',
626 * @dataProvider provideSuppressEventLogDatabaseRows
628 public function testSuppressEventLogDatabaseRows( $row, $extra ) {
630 'wgGroupPermissions',
633 'viewsuppressed' => true,
634 'suppressionlog' => true,
638 $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] );
642 * Provide different rows from the logging table to test
643 * for backward compatibility.
644 * Do not change the existing data, just add a new database row
646 public static function provideSuppressEventLogDatabaseRowsNonPrivileged() {
651 'type' => 'suppress',
653 'comment' => 'Suppress comment',
654 'namespace' => NS_MAIN
,
657 '4::ids' => [ '1', '3', '4' ],
663 'text' => '(username removed) (log details removed)',
666 'ids' => [ '1', '3', '4' ],
672 'restricted' => false,
679 'restricted' => true,
688 'type' => 'suppress',
690 'comment' => 'Suppress comment',
691 'namespace' => NS_MAIN
,
701 'text' => '(username removed) (log details removed)',
704 'ids' => [ '1', '3', '4' ],
710 'restricted' => false,
717 'restricted' => true,
726 * @dataProvider provideSuppressEventLogDatabaseRowsNonPrivileged
728 public function testSuppressEventLogDatabaseRowsNonPrivileged( $row, $extra ) {
729 $this->user
= $this->getTestUser()->getUser();
730 $this->doTestLogFormatter( $row, $extra );
734 * Provide different rows from the logging table to test
735 * for backward compatibility.
736 * Do not change the existing data, just add a new database row
738 public static function provideSuppressDeleteLogDatabaseRows() {
743 'type' => 'suppress',
744 'action' => 'delete',
745 'comment' => 'delete comment',
746 'namespace' => NS_MAIN
,
751 'text' => 'User suppressed page Page',
759 'type' => 'suppress',
760 'action' => 'delete',
761 'comment' => 'delete comment',
762 'namespace' => NS_MAIN
,
768 'text' => 'User suppressed page Page',
776 * @dataProvider provideSuppressDeleteLogDatabaseRows
778 public function testSuppressDeleteLogDatabaseRows( $row, $extra ) {
780 'wgGroupPermissions',
783 'viewsuppressed' => true,
784 'suppressionlog' => true,
788 $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] );
792 * Provide different rows from the logging table to test
793 * for backward compatibility.
794 * Do not change the existing data, just add a new database row
796 public static function provideSuppressDeleteLogDatabaseRowsNonPrivileged() {
801 'type' => 'suppress',
802 'action' => 'delete',
803 'comment' => 'delete comment',
804 'namespace' => NS_MAIN
,
809 'text' => '(username removed) (log details removed)',
817 'type' => 'suppress',
818 'action' => 'delete',
819 'comment' => 'delete comment',
820 'namespace' => NS_MAIN
,
826 'text' => '(username removed) (log details removed)',
834 * @dataProvider provideSuppressDeleteLogDatabaseRowsNonPrivileged
836 public function testSuppressDeleteLogDatabaseRowsNonPrivileged( $row, $extra ) {
837 $this->user
= $this->getTestUser()->getUser();
838 $this->doTestLogFormatter( $row, $extra );