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' ],
45 'comment' => 'Block comment',
47 'user_text' => 'Sysop',
48 'namespace' => NS_USER
,
49 'title' => 'Logtestuser',
57 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
58 . ' (anonymous users only)',
60 'duration' => 'infinite',
61 'flags' => [ 'anononly' ],
66 // Old legacy log without flag
71 'comment' => 'Block comment',
73 'user_text' => 'Sysop',
74 'namespace' => NS_USER
,
75 'title' => 'Logtestuser',
82 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite',
84 'duration' => 'infinite',
90 // Very old legacy log without duration
95 'comment' => 'Block comment',
97 'user_text' => 'Sysop',
98 'namespace' => NS_USER
,
99 'title' => 'Logtestuser',
104 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite',
106 'duration' => 'infinite',
115 * @dataProvider provideBlockLogDatabaseRows
117 public function testBlockLogDatabaseRows( $row, $extra ) {
118 $this->doTestLogFormatter( $row, $extra );
122 * Provide different rows from the logging table to test
123 * for backward compatibility.
124 * Do not change the existing data, just add a new database row
126 public static function provideReblockLogDatabaseRows() {
128 // Current log format
132 'action' => 'reblock',
133 'comment' => 'Block comment',
135 'user_text' => 'Sysop',
136 'namespace' => NS_USER
,
137 'title' => 'Logtestuser',
139 '5::duration' => 'infinite',
140 '6::flags' => 'anononly',
144 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
145 . ' indefinite (anonymous users only)',
147 'duration' => 'infinite',
148 'flags' => [ 'anononly' ],
157 'action' => 'reblock',
158 'comment' => 'Block comment',
160 'user_text' => 'Sysop',
161 'namespace' => NS_USER
,
162 'title' => 'Logtestuser',
170 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
171 . ' indefinite (anonymous users only)',
173 'duration' => 'infinite',
174 'flags' => [ 'anononly' ],
179 // Older log without flag
183 'action' => 'reblock',
184 'comment' => 'Block comment',
186 'user_text' => 'Sysop',
187 'namespace' => NS_USER
,
188 'title' => 'Logtestuser',
195 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of indefinite',
197 'duration' => 'infinite',
206 * @dataProvider provideReblockLogDatabaseRows
208 public function testReblockLogDatabaseRows( $row, $extra ) {
209 $this->doTestLogFormatter( $row, $extra );
213 * Provide different rows from the logging table to test
214 * for backward compatibility.
215 * Do not change the existing data, just add a new database row
217 public static function provideUnblockLogDatabaseRows() {
219 // Current log format
223 'action' => 'unblock',
224 'comment' => 'Block comment',
226 'user_text' => 'Sysop',
227 'namespace' => NS_USER
,
228 'title' => 'Logtestuser',
232 'text' => 'Sysop unblocked Logtestuser',
240 * @dataProvider provideUnblockLogDatabaseRows
242 public function testUnblockLogDatabaseRows( $row, $extra ) {
243 $this->doTestLogFormatter( $row, $extra );
247 * Provide different rows from the logging table to test
248 * for backward compatibility.
249 * Do not change the existing data, just add a new database row
251 public static function provideSuppressBlockLogDatabaseRows() {
253 // Current log format
256 'type' => 'suppress',
258 'comment' => 'Block comment',
260 'user_text' => 'Sysop',
261 'namespace' => NS_USER
,
262 'title' => 'Logtestuser',
264 '5::duration' => 'infinite',
265 '6::flags' => 'anononly',
269 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
270 . ' (anonymous users only)',
272 'duration' => 'infinite',
273 'flags' => [ 'anononly' ],
281 'type' => 'suppress',
283 'comment' => 'Block comment',
285 'user_text' => 'Sysop',
286 'namespace' => NS_USER
,
287 'title' => 'Logtestuser',
295 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
296 . ' (anonymous users only)',
298 'duration' => 'infinite',
299 'flags' => [ 'anononly' ],
307 * @dataProvider provideSuppressBlockLogDatabaseRows
309 public function testSuppressBlockLogDatabaseRows( $row, $extra ) {
311 'wgGroupPermissions',
314 'viewsuppressed' => true,
315 'suppressionlog' => true,
319 $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] );
323 * Provide different rows from the logging table to test
324 * for backward compatibility.
325 * Do not change the existing data, just add a new database row
327 public static function provideSuppressBlockLogDatabaseRowsNonPrivileged() {
329 // Current log format
332 'type' => 'suppress',
334 'comment' => 'Block comment',
336 'user_text' => 'Sysop',
337 'namespace' => NS_USER
,
338 'title' => 'Logtestuser',
340 '5::duration' => 'infinite',
341 '6::flags' => 'anononly',
345 'text' => '(username removed) (log details removed)',
347 'duration' => 'infinite',
348 'flags' => [ 'anononly' ],
356 'type' => 'suppress',
358 'comment' => 'Block comment',
360 'user_text' => 'Sysop',
361 'namespace' => NS_USER
,
362 'title' => 'Logtestuser',
370 'text' => '(username removed) (log details removed)',
372 'duration' => 'infinite',
373 'flags' => [ 'anononly' ],
381 * @dataProvider provideSuppressBlockLogDatabaseRowsNonPrivileged
383 public function testSuppressBlockLogDatabaseRowsNonPrivileged( $row, $extra ) {
384 $this->user
= $this->getTestUser()->getUser();
385 $this->doTestLogFormatter( $row, $extra );
389 * Provide different rows from the logging table to test
390 * for backward compatibility.
391 * Do not change the existing data, just add a new database row
393 public static function provideSuppressReblockLogDatabaseRows() {
395 // Current log format
398 'type' => 'suppress',
399 'action' => 'reblock',
400 'comment' => 'Block comment',
402 'user_text' => 'Sysop',
403 'namespace' => NS_USER
,
404 'title' => 'Logtestuser',
406 '5::duration' => 'infinite',
407 '6::flags' => 'anononly',
411 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
412 . ' indefinite (anonymous users only)',
414 'duration' => 'infinite',
415 'flags' => [ 'anononly' ],
423 'type' => 'suppress',
424 'action' => 'reblock',
425 'comment' => 'Block comment',
427 'user_text' => 'Sysop',
428 'namespace' => NS_USER
,
429 'title' => 'Logtestuser',
437 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
438 . ' indefinite (anonymous users only)',
440 'duration' => 'infinite',
441 'flags' => [ 'anononly' ],
449 * @dataProvider provideSuppressReblockLogDatabaseRows
451 public function testSuppressReblockLogDatabaseRows( $row, $extra ) {
453 'wgGroupPermissions',
456 'viewsuppressed' => true,
457 'suppressionlog' => true,
461 $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] );
465 * Provide different rows from the logging table to test
466 * for backward compatibility.
467 * Do not change the existing data, just add a new database row
469 public static function provideSuppressReblockLogDatabaseRowsNonPrivileged() {
471 // Current log format
474 'type' => 'suppress',
475 'action' => 'reblock',
476 'comment' => 'Block comment',
478 'user_text' => 'Sysop',
479 'namespace' => NS_USER
,
480 'title' => 'Logtestuser',
482 '5::duration' => 'infinite',
483 '6::flags' => 'anononly',
487 'text' => '(username removed) (log details removed)',
489 'duration' => 'infinite',
490 'flags' => [ 'anononly' ],
498 'type' => 'suppress',
499 'action' => 'reblock',
500 'comment' => 'Block comment',
502 'user_text' => 'Sysop',
503 'namespace' => NS_USER
,
504 'title' => 'Logtestuser',
512 'text' => '(username removed) (log details removed)',
514 'duration' => 'infinite',
515 'flags' => [ 'anononly' ],
523 * @dataProvider provideSuppressReblockLogDatabaseRowsNonPrivileged
525 public function testSuppressReblockLogDatabaseRowsNonPrivileged( $row, $extra ) {
526 $this->user
= $this->getTestUser()->getUser();
527 $this->doTestLogFormatter( $row, $extra );
530 public function providePartialBlockLogDatabaseRows() {
536 'comment' => 'Block comment',
538 'user_text' => 'Sysop',
539 'namespace' => NS_USER
,
540 'title' => 'Logtestuser',
542 '5::duration' => 'infinite',
543 '6::flags' => 'anononly',
544 '7::restrictions' => [ 'pages' => [ 'User:Test1', 'Main Page' ] ],
549 'text' => 'Sysop blocked Logtestuser from editing the pages User:Test1 and Main Page'
550 . ' with an expiration time of indefinite (anonymous users only)',
552 'duration' => 'infinite',
553 'flags' => [ 'anononly' ],
558 'page_title' => 'User:Test1',
561 'page_title' => 'Main Page',
573 'comment' => 'Block comment',
575 'user_text' => 'Sysop',
576 'namespace' => NS_USER
,
577 'title' => 'Logtestuser',
579 '5::duration' => 'infinite',
580 '6::flags' => 'anononly',
581 '7::restrictions' => [
582 'namespaces' => [ NS_USER
],
588 'text' => 'Sysop blocked Logtestuser from editing the namespace User'
589 . ' with an expiration time of indefinite (anonymous users only)',
591 'duration' => 'infinite',
592 'flags' => [ 'anononly' ],
594 'namespaces' => [ NS_USER
],
604 'comment' => 'Block comment',
606 'user_text' => 'Sysop',
607 'namespace' => NS_USER
,
608 'title' => 'Logtestuser',
610 '5::duration' => 'infinite',
611 '6::flags' => 'anononly',
612 '7::restrictions' => [
613 'pages' => [ 'Main Page' ],
614 'namespaces' => [ NS_USER
, NS_MAIN
],
620 'text' => 'Sysop blocked Logtestuser from editing the page Main Page and the'
621 . ' namespaces User and (Main) with an expiration time of indefinite'
622 . ' (anonymous users only)',
624 'duration' => 'infinite',
625 'flags' => [ 'anononly' ],
630 'page_title' => 'Main Page',
633 'namespaces' => [ NS_USER
, NS_MAIN
],
643 'comment' => 'Block comment',
645 'user_text' => 'Sysop',
646 'namespace' => NS_USER
,
647 'title' => 'Logtestuser',
649 '5::duration' => 'infinite',
650 '6::flags' => 'anononly',
655 'text' => 'Sysop blocked Logtestuser from specified non-editing actions'
656 . ' with an expiration time of indefinite (anonymous users only)',
658 'duration' => 'infinite',
659 'flags' => [ 'anononly' ],
668 * @dataProvider providePartialBlockLogDatabaseRows
670 public function testPartialBlockLogDatabaseRows( $row, $extra ) {
671 $this->doTestLogFormatter( $row, $extra );