4 * @covers BlockLogFormatter
6 class BlockLogFormatterTest
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 provideBlockLogDatabaseRows() {
20 'comment' => 'Block comment',
22 'user_text' => 'Sysop',
23 'namespace' => NS_USER
,
24 'title' => 'Logtestuser',
26 '5::duration' => 'infinite',
27 '6::flags' => 'anononly',
31 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
32 . ' (anonymous users only)',
34 'duration' => 'infinite',
35 'flags' => [ 'anononly' ],
37 'preload' => [ new TitleValue( NS_USER_TALK
, 'Logtestuser' ) ],
41 // With blank page title (T224811)
46 'comment' => 'Block comment',
48 'user_text' => 'Sysop',
49 'namespace' => NS_USER
,
54 'text' => 'Sysop blocked (no username available) '
55 . 'with an expiration time of indefinite',
57 'duration' => 'infinite',
69 'comment' => 'Block comment',
71 'user_text' => 'Sysop',
72 'namespace' => NS_USER
,
73 'title' => 'Logtestuser',
81 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
82 . ' (anonymous users only)',
84 'duration' => 'infinite',
85 'flags' => [ 'anononly' ],
90 // Old legacy log without flag
95 'comment' => 'Block comment',
97 'user_text' => 'Sysop',
98 'namespace' => NS_USER
,
99 'title' => 'Logtestuser',
106 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite',
108 'duration' => 'infinite',
114 // Very old legacy log without duration
119 'comment' => 'Block comment',
121 'user_text' => 'Sysop',
122 'namespace' => NS_USER
,
123 'title' => 'Logtestuser',
128 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite',
130 'duration' => 'infinite',
139 * @dataProvider provideBlockLogDatabaseRows
141 public function testBlockLogDatabaseRows( $row, $extra ) {
142 $this->doTestLogFormatter( $row, $extra );
146 * Provide different rows from the logging table to test
147 * for backward compatibility.
148 * Do not change the existing data, just add a new database row
150 public static function provideReblockLogDatabaseRows() {
152 // Current log format
156 'action' => 'reblock',
157 'comment' => 'Block comment',
159 'user_text' => 'Sysop',
160 'namespace' => NS_USER
,
161 'title' => 'Logtestuser',
163 '5::duration' => 'infinite',
164 '6::flags' => 'anononly',
168 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
169 . ' indefinite (anonymous users only)',
171 'duration' => 'infinite',
172 'flags' => [ 'anononly' ],
181 'action' => 'reblock',
182 'comment' => 'Block comment',
184 'user_text' => 'Sysop',
185 'namespace' => NS_USER
,
186 'title' => 'Logtestuser',
194 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
195 . ' indefinite (anonymous users only)',
197 'duration' => 'infinite',
198 'flags' => [ 'anononly' ],
203 // Older log without flag
207 'action' => 'reblock',
208 'comment' => 'Block comment',
210 'user_text' => 'Sysop',
211 'namespace' => NS_USER
,
212 'title' => 'Logtestuser',
219 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of indefinite',
221 'duration' => 'infinite',
230 * @dataProvider provideReblockLogDatabaseRows
232 public function testReblockLogDatabaseRows( $row, $extra ) {
233 $this->doTestLogFormatter( $row, $extra );
237 * Provide different rows from the logging table to test
238 * for backward compatibility.
239 * Do not change the existing data, just add a new database row
241 public static function provideUnblockLogDatabaseRows() {
243 // Current log format
247 'action' => 'unblock',
248 'comment' => 'Block comment',
250 'user_text' => 'Sysop',
251 'namespace' => NS_USER
,
252 'title' => 'Logtestuser',
256 'text' => 'Sysop unblocked Logtestuser',
264 * @dataProvider provideUnblockLogDatabaseRows
266 public function testUnblockLogDatabaseRows( $row, $extra ) {
267 $this->doTestLogFormatter( $row, $extra );
271 * Provide different rows from the logging table to test
272 * for backward compatibility.
273 * Do not change the existing data, just add a new database row
275 public static function provideSuppressBlockLogDatabaseRows() {
277 // Current log format
280 'type' => 'suppress',
282 'comment' => 'Block comment',
284 'user_text' => 'Sysop',
285 'namespace' => NS_USER
,
286 'title' => 'Logtestuser',
288 '5::duration' => 'infinite',
289 '6::flags' => 'anononly',
293 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
294 . ' (anonymous users only)',
296 'duration' => 'infinite',
297 'flags' => [ 'anononly' ],
305 'type' => 'suppress',
307 'comment' => 'Block comment',
309 'user_text' => 'Sysop',
310 'namespace' => NS_USER
,
311 'title' => 'Logtestuser',
319 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
320 . ' (anonymous users only)',
322 'duration' => 'infinite',
323 'flags' => [ 'anononly' ],
331 * @dataProvider provideSuppressBlockLogDatabaseRows
333 public function testSuppressBlockLogDatabaseRows( $row, $extra ) {
335 'wgGroupPermissions',
338 'viewsuppressed' => true,
339 'suppressionlog' => true,
343 $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] );
347 * Provide different rows from the logging table to test
348 * for backward compatibility.
349 * Do not change the existing data, just add a new database row
351 public static function provideSuppressBlockLogDatabaseRowsNonPrivileged() {
353 // Current log format
356 'type' => 'suppress',
358 'comment' => 'Block comment',
360 'user_text' => 'Sysop',
361 'namespace' => NS_USER
,
362 'title' => 'Logtestuser',
364 '5::duration' => 'infinite',
365 '6::flags' => 'anononly',
369 'text' => '(username removed) (log details removed)',
371 'duration' => 'infinite',
372 'flags' => [ 'anononly' ],
380 'type' => 'suppress',
382 'comment' => 'Block comment',
384 'user_text' => 'Sysop',
385 'namespace' => NS_USER
,
386 'title' => 'Logtestuser',
394 'text' => '(username removed) (log details removed)',
396 'duration' => 'infinite',
397 'flags' => [ 'anononly' ],
405 * @dataProvider provideSuppressBlockLogDatabaseRowsNonPrivileged
407 public function testSuppressBlockLogDatabaseRowsNonPrivileged( $row, $extra ) {
408 $this->user
= $this->getTestUser()->getUser();
409 $this->doTestLogFormatter( $row, $extra );
413 * Provide different rows from the logging table to test
414 * for backward compatibility.
415 * Do not change the existing data, just add a new database row
417 public static function provideSuppressReblockLogDatabaseRows() {
419 // Current log format
422 'type' => 'suppress',
423 'action' => 'reblock',
424 'comment' => 'Block comment',
426 'user_text' => 'Sysop',
427 'namespace' => NS_USER
,
428 'title' => 'Logtestuser',
430 '5::duration' => 'infinite',
431 '6::flags' => 'anononly',
435 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
436 . ' indefinite (anonymous users only)',
438 'duration' => 'infinite',
439 'flags' => [ 'anononly' ],
447 'type' => 'suppress',
448 'action' => 'reblock',
449 'comment' => 'Block comment',
451 'user_text' => 'Sysop',
452 'namespace' => NS_USER
,
453 'title' => 'Logtestuser',
461 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
462 . ' indefinite (anonymous users only)',
464 'duration' => 'infinite',
465 'flags' => [ 'anononly' ],
473 * @dataProvider provideSuppressReblockLogDatabaseRows
475 public function testSuppressReblockLogDatabaseRows( $row, $extra ) {
477 'wgGroupPermissions',
480 'viewsuppressed' => true,
481 'suppressionlog' => true,
485 $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] );
489 * Provide different rows from the logging table to test
490 * for backward compatibility.
491 * Do not change the existing data, just add a new database row
493 public static function provideSuppressReblockLogDatabaseRowsNonPrivileged() {
495 // Current log format
498 'type' => 'suppress',
499 'action' => 'reblock',
500 'comment' => 'Block comment',
502 'user_text' => 'Sysop',
503 'namespace' => NS_USER
,
504 'title' => 'Logtestuser',
506 '5::duration' => 'infinite',
507 '6::flags' => 'anononly',
511 'text' => '(username removed) (log details removed)',
513 'duration' => 'infinite',
514 'flags' => [ 'anononly' ],
522 'type' => 'suppress',
523 'action' => 'reblock',
524 'comment' => 'Block comment',
526 'user_text' => 'Sysop',
527 'namespace' => NS_USER
,
528 'title' => 'Logtestuser',
536 'text' => '(username removed) (log details removed)',
538 'duration' => 'infinite',
539 'flags' => [ 'anononly' ],
547 * @dataProvider provideSuppressReblockLogDatabaseRowsNonPrivileged
549 public function testSuppressReblockLogDatabaseRowsNonPrivileged( $row, $extra ) {
550 $this->user
= $this->getTestUser()->getUser();
551 $this->doTestLogFormatter( $row, $extra );
554 public function providePartialBlockLogDatabaseRows() {
560 'comment' => 'Block comment',
562 'user_text' => 'Sysop',
563 'namespace' => NS_USER
,
564 'title' => 'Logtestuser',
566 '5::duration' => 'infinite',
567 '6::flags' => 'anononly',
568 '7::restrictions' => [ 'pages' => [ 'User:Test1', 'Main Page' ] ],
573 'text' => 'Sysop blocked Logtestuser from editing the pages User:Test1 and Main Page'
574 . ' with an expiration time of indefinite (anonymous users only)',
576 'duration' => 'infinite',
577 'flags' => [ 'anononly' ],
582 'page_title' => 'User:Test1',
585 'page_title' => 'Main Page',
597 'comment' => 'Block comment',
599 'user_text' => 'Sysop',
600 'namespace' => NS_USER
,
601 'title' => 'Logtestuser',
603 '5::duration' => 'infinite',
604 '6::flags' => 'anononly',
605 '7::restrictions' => [
606 'namespaces' => [ NS_USER
],
612 'text' => 'Sysop blocked Logtestuser from editing the namespace User'
613 . ' with an expiration time of indefinite (anonymous users only)',
615 'duration' => 'infinite',
616 'flags' => [ 'anononly' ],
618 'namespaces' => [ NS_USER
],
628 'comment' => 'Block comment',
630 'user_text' => 'Sysop',
631 'namespace' => NS_USER
,
632 'title' => 'Logtestuser',
634 '5::duration' => 'infinite',
635 '6::flags' => 'anononly',
636 '7::restrictions' => [
637 'pages' => [ 'Main Page' ],
638 'namespaces' => [ NS_USER
, NS_MAIN
],
644 'text' => 'Sysop blocked Logtestuser from editing the page Main Page and the'
645 . ' namespaces User and (Main) with an expiration time of indefinite'
646 . ' (anonymous users only)',
648 'duration' => 'infinite',
649 'flags' => [ 'anononly' ],
654 'page_title' => 'Main Page',
657 'namespaces' => [ NS_USER
, NS_MAIN
],
667 'comment' => 'Block comment',
669 'user_text' => 'Sysop',
670 'namespace' => NS_USER
,
671 'title' => 'Logtestuser',
673 '5::duration' => 'infinite',
674 '6::flags' => 'anononly',
679 'text' => 'Sysop blocked Logtestuser from specified non-editing actions'
680 . ' with an expiration time of indefinite (anonymous users only)',
682 'duration' => 'infinite',
683 'flags' => [ 'anononly' ],
692 * @dataProvider providePartialBlockLogDatabaseRows
694 public function testPartialBlockLogDatabaseRows( $row, $extra ) {
695 $this->doTestLogFormatter( $row, $extra );