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 ) {
310 $this->doTestLogFormatter( $row, $extra );
314 * Provide different rows from the logging table to test
315 * for backward compatibility.
316 * Do not change the existing data, just add a new database row
318 public static function provideSuppressReblockLogDatabaseRows() {
320 // Current log format
323 'type' => 'suppress',
324 'action' => 'reblock',
325 'comment' => 'Block comment',
327 'user_text' => 'Sysop',
328 'namespace' => NS_USER
,
329 'title' => 'Logtestuser',
331 '5::duration' => 'infinite',
332 '6::flags' => 'anononly',
336 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
337 . ' indefinite (anonymous users only)',
339 'duration' => 'infinite',
340 'flags' => [ 'anononly' ],
348 'type' => 'suppress',
349 'action' => 'reblock',
350 'comment' => 'Block comment',
352 'user_text' => 'Sysop',
353 'namespace' => NS_USER
,
354 'title' => 'Logtestuser',
362 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
363 . ' indefinite (anonymous users only)',
365 'duration' => 'infinite',
366 'flags' => [ 'anononly' ],
374 * @dataProvider provideSuppressReblockLogDatabaseRows
376 public function testSuppressReblockLogDatabaseRows( $row, $extra ) {
377 $this->doTestLogFormatter( $row, $extra );
380 public function providePartialBlockLogDatabaseRows() {
386 'comment' => 'Block comment',
388 'user_text' => 'Sysop',
389 'namespace' => NS_USER
,
390 'title' => 'Logtestuser',
392 '5::duration' => 'infinite',
393 '6::flags' => 'anononly',
394 '7::restrictions' => [ 'pages' => [ 'User:Test1', 'Main Page' ] ],
399 'text' => 'Sysop blocked Logtestuser from editing the pages User:Test1 and Main Page'
400 . ' with an expiration time of indefinite (anonymous users only)',
402 'duration' => 'infinite',
403 'flags' => [ 'anononly' ],
404 'restrictions' => [ 'pages' => [
407 'page_title' => 'User:Test1',
410 'page_title' => 'Main Page',
422 'comment' => 'Block comment',
424 'user_text' => 'Sysop',
425 'namespace' => NS_USER
,
426 'title' => 'Logtestuser',
428 '5::duration' => 'infinite',
429 '6::flags' => 'anononly',
434 'text' => 'Sysop blocked Logtestuser from non-editing actions'
435 . ' with an expiration time of indefinite (anonymous users only)',
437 'duration' => 'infinite',
438 'flags' => [ 'anononly' ],
447 * @dataProvider providePartialBlockLogDatabaseRows
449 public function testPartialBlockLogDatabaseRows( $row, $extra ) {
450 $this->doTestLogFormatter( $row, $extra );