3 class ProtectLogFormatterTest
extends LogFormatterTestCase
{
6 * Provide different rows from the logging table to test
7 * for backward compatibility.
8 * Do not change the existing data, just add a new database row
10 public static function provideProtectLogDatabaseRows() {
16 'action' => 'protect',
17 'comment' => 'protect comment',
18 'namespace' => NS_MAIN
,
19 'title' => 'ProtectPage',
21 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
22 '5:bool:cascade' => false,
27 'expiry' => 'infinity',
33 'expiry' => 'infinity',
40 'text' => 'User protected ProtectPage [Edit=Allow only administrators] ' .
41 '(indefinite) [Move=Allow only administrators] (indefinite)',
43 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
49 'expiry' => 'infinite',
55 'expiry' => 'infinite',
63 // Current format with cascade
67 'action' => 'protect',
68 'comment' => 'protect comment',
69 'namespace' => NS_MAIN
,
70 'title' => 'ProtectPage',
72 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
73 '5:bool:cascade' => true,
78 'expiry' => 'infinity',
84 'expiry' => 'infinity',
91 'text' => 'User protected ProtectPage [Edit=Allow only administrators] ' .
92 '(indefinite) [Move=Allow only administrators] (indefinite) [cascading]',
94 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
100 'expiry' => 'infinite',
106 'expiry' => 'infinite',
118 'action' => 'protect',
119 'comment' => 'protect comment',
120 'namespace' => NS_MAIN
,
121 'title' => 'ProtectPage',
123 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
129 'text' => 'User protected ProtectPage [edit=sysop] (indefinite)[move=sysop] (indefinite)',
131 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
137 // Legacy format with cascade
141 'action' => 'protect',
142 'comment' => 'protect comment',
143 'namespace' => NS_MAIN
,
144 'title' => 'ProtectPage',
146 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
152 'text' => 'User protected ProtectPage [edit=sysop] ' .
153 '(indefinite)[move=sysop] (indefinite) [cascading]',
155 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
165 * @dataProvider provideProtectLogDatabaseRows
167 public function testProtectLogDatabaseRows( $row, $extra ) {
168 $this->doTestLogFormatter( $row, $extra );
172 * Provide different rows from the logging table to test
173 * for backward compatibility.
174 * Do not change the existing data, just add a new database row
176 public static function provideModifyLogDatabaseRows() {
182 'action' => 'modify',
183 'comment' => 'protect comment',
184 'namespace' => NS_MAIN
,
185 'title' => 'ProtectPage',
187 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
188 '5:bool:cascade' => false,
193 'expiry' => 'infinity',
199 'expiry' => 'infinity',
206 'text' => 'User changed protection level for ProtectPage ' .
207 '[Edit=Allow only administrators] ' .
208 '(indefinite) [Move=Allow only administrators] (indefinite)',
210 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
216 'expiry' => 'infinite',
222 'expiry' => 'infinite',
230 // Current format with cascade
234 'action' => 'modify',
235 'comment' => 'protect comment',
236 'namespace' => NS_MAIN
,
237 'title' => 'ProtectPage',
239 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
240 '5:bool:cascade' => true,
245 'expiry' => 'infinity',
251 'expiry' => 'infinity',
258 'text' => 'User changed protection level for ProtectPage [Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite) [cascading]',
260 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
266 'expiry' => 'infinite',
272 'expiry' => 'infinite',
284 'action' => 'modify',
285 'comment' => 'protect comment',
286 'namespace' => NS_MAIN
,
287 'title' => 'ProtectPage',
289 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
295 'text' => 'User changed protection level for ProtectPage ' .
296 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
298 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
304 // Legacy format with cascade
308 'action' => 'modify',
309 'comment' => 'protect comment',
310 'namespace' => NS_MAIN
,
311 'title' => 'ProtectPage',
313 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
319 'text' => 'User changed protection level for ProtectPage ' .
320 '[edit=sysop] (indefinite)[move=sysop] (indefinite) [cascading]',
322 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
332 * @dataProvider provideModifyLogDatabaseRows
334 public function testModifyLogDatabaseRows( $row, $extra ) {
335 $this->doTestLogFormatter( $row, $extra );
339 * Provide different rows from the logging table to test
340 * for backward compatibility.
341 * Do not change the existing data, just add a new database row
343 public static function provideUnprotectLogDatabaseRows() {
349 'action' => 'unprotect',
350 'comment' => 'unprotect comment',
351 'namespace' => NS_MAIN
,
352 'title' => 'ProtectPage',
356 'text' => 'User removed protection from ProtectPage',
365 * @dataProvider provideUnprotectLogDatabaseRows
367 public function testUnprotectLogDatabaseRows( $row, $extra ) {
368 $this->doTestLogFormatter( $row, $extra );
372 * Provide different rows from the logging table to test
373 * for backward compatibility.
374 * Do not change the existing data, just add a new database row
376 public static function provideMoveProtLogDatabaseRows() {
382 'action' => 'move_prot',
383 'comment' => 'Move comment',
384 'namespace' => NS_MAIN
,
385 'title' => 'NewPage',
387 '4::oldtitle' => 'OldPage',
391 'text' => 'User moved protection settings from OldPage to NewPage',
394 'oldtitle_title' => 'OldPage',
403 'action' => 'move_prot',
404 'comment' => 'Move comment',
405 'namespace' => NS_MAIN
,
406 'title' => 'NewPage',
413 'text' => 'User moved protection settings from OldPage to NewPage',
416 'oldtitle_title' => 'OldPage',
424 * @dataProvider provideMoveProtLogDatabaseRows
426 public function testMoveProtLogDatabaseRows( $row, $extra ) {
427 $this->doTestLogFormatter( $row, $extra );