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 ' .
259 '[Edit=Allow only administrators] (indefinite) ' .
260 '[Move=Allow only administrators] (indefinite) [cascading]',
262 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
268 'expiry' => 'infinite',
274 'expiry' => 'infinite',
286 'action' => 'modify',
287 'comment' => 'protect comment',
288 'namespace' => NS_MAIN
,
289 'title' => 'ProtectPage',
291 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
297 'text' => 'User changed protection level for ProtectPage ' .
298 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
300 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
306 // Legacy format with cascade
310 'action' => 'modify',
311 'comment' => 'protect comment',
312 'namespace' => NS_MAIN
,
313 'title' => 'ProtectPage',
315 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
321 'text' => 'User changed protection level for ProtectPage ' .
322 '[edit=sysop] (indefinite)[move=sysop] (indefinite) [cascading]',
324 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
334 * @dataProvider provideModifyLogDatabaseRows
336 public function testModifyLogDatabaseRows( $row, $extra ) {
337 $this->doTestLogFormatter( $row, $extra );
341 * Provide different rows from the logging table to test
342 * for backward compatibility.
343 * Do not change the existing data, just add a new database row
345 public static function provideUnprotectLogDatabaseRows() {
351 'action' => 'unprotect',
352 'comment' => 'unprotect comment',
353 'namespace' => NS_MAIN
,
354 'title' => 'ProtectPage',
358 'text' => 'User removed protection from ProtectPage',
367 * @dataProvider provideUnprotectLogDatabaseRows
369 public function testUnprotectLogDatabaseRows( $row, $extra ) {
370 $this->doTestLogFormatter( $row, $extra );
374 * Provide different rows from the logging table to test
375 * for backward compatibility.
376 * Do not change the existing data, just add a new database row
378 public static function provideMoveProtLogDatabaseRows() {
384 'action' => 'move_prot',
385 'comment' => 'Move comment',
386 'namespace' => NS_MAIN
,
387 'title' => 'NewPage',
389 '4::oldtitle' => 'OldPage',
393 'text' => 'User moved protection settings from OldPage to NewPage',
396 'oldtitle_title' => 'OldPage',
405 'action' => 'move_prot',
406 'comment' => 'Move comment',
407 'namespace' => NS_MAIN
,
408 'title' => 'NewPage',
415 'text' => 'User moved protection settings from OldPage to NewPage',
418 'oldtitle_title' => 'OldPage',
426 * @dataProvider provideMoveProtLogDatabaseRows
428 public function testMoveProtLogDatabaseRows( $row, $extra ) {
429 $this->doTestLogFormatter( $row, $extra );