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 ) {
334 $this->doTestLogFormatter( $row, $extra );
338 * Provide different rows from the logging table to test
339 * for backward compatibility.
340 * Do not change the existing data, just add a new database row
342 public static function provideSuppressReblockLogDatabaseRows() {
344 // Current log format
347 'type' => 'suppress',
348 'action' => 'reblock',
349 'comment' => 'Block comment',
351 'user_text' => 'Sysop',
352 'namespace' => NS_USER
,
353 'title' => 'Logtestuser',
355 '5::duration' => 'infinite',
356 '6::flags' => 'anononly',
360 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
361 . ' indefinite (anonymous users only)',
363 'duration' => 'infinite',
364 'flags' => [ 'anononly' ],
372 'type' => 'suppress',
373 'action' => 'reblock',
374 'comment' => 'Block comment',
376 'user_text' => 'Sysop',
377 'namespace' => NS_USER
,
378 'title' => 'Logtestuser',
386 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
387 . ' indefinite (anonymous users only)',
389 'duration' => 'infinite',
390 'flags' => [ 'anononly' ],
398 * @dataProvider provideSuppressReblockLogDatabaseRows
400 public function testSuppressReblockLogDatabaseRows( $row, $extra ) {
401 $this->doTestLogFormatter( $row, $extra );
404 public function providePartialBlockLogDatabaseRows() {
410 'comment' => 'Block comment',
412 'user_text' => 'Sysop',
413 'namespace' => NS_USER
,
414 'title' => 'Logtestuser',
416 '5::duration' => 'infinite',
417 '6::flags' => 'anononly',
418 '7::restrictions' => [ 'pages' => [ 'User:Test1', 'Main Page' ] ],
423 'text' => 'Sysop blocked Logtestuser from editing the pages User:Test1 and Main Page'
424 . ' with an expiration time of indefinite (anonymous users only)',
426 'duration' => 'infinite',
427 'flags' => [ 'anononly' ],
432 'page_title' => 'User:Test1',
435 'page_title' => 'Main Page',
447 'comment' => 'Block comment',
449 'user_text' => 'Sysop',
450 'namespace' => NS_USER
,
451 'title' => 'Logtestuser',
453 '5::duration' => 'infinite',
454 '6::flags' => 'anononly',
455 '7::restrictions' => [
456 'namespaces' => [ NS_USER
],
462 'text' => 'Sysop blocked Logtestuser from editing the namespace User'
463 . ' with an expiration time of indefinite (anonymous users only)',
465 'duration' => 'infinite',
466 'flags' => [ 'anononly' ],
468 'namespaces' => [ NS_USER
],
478 'comment' => 'Block comment',
480 'user_text' => 'Sysop',
481 'namespace' => NS_USER
,
482 'title' => 'Logtestuser',
484 '5::duration' => 'infinite',
485 '6::flags' => 'anononly',
486 '7::restrictions' => [
487 'pages' => [ 'Main Page' ],
488 'namespaces' => [ NS_USER
, NS_MAIN
],
494 'text' => 'Sysop blocked Logtestuser from editing the page Main Page and the'
495 . ' namespaces User and (Main) with an expiration time of indefinite'
496 . ' (anonymous users only)',
498 'duration' => 'infinite',
499 'flags' => [ 'anononly' ],
504 'page_title' => 'Main Page',
507 'namespaces' => [ NS_USER
, NS_MAIN
],
517 'comment' => 'Block comment',
519 'user_text' => 'Sysop',
520 'namespace' => NS_USER
,
521 'title' => 'Logtestuser',
523 '5::duration' => 'infinite',
524 '6::flags' => 'anononly',
529 'text' => 'Sysop blocked Logtestuser from specified non-editing actions'
530 . ' with an expiration time of indefinite (anonymous users only)',
532 'duration' => 'infinite',
533 'flags' => [ 'anononly' ],
542 * @dataProvider providePartialBlockLogDatabaseRows
544 public function testPartialBlockLogDatabaseRows( $row, $extra ) {
545 $this->doTestLogFormatter( $row, $extra );