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)',
164 * @dataProvider provideProtectLogDatabaseRows
166 public function testProtectLogDatabaseRows( $row, $extra ) {
167 $this->doTestLogFormatter( $row, $extra );
171 * Provide different rows from the logging table to test
172 * for backward compatibility.
173 * Do not change the existing data, just add a new database row
175 public static function provideModifyLogDatabaseRows() {
181 'action' => 'modify',
182 'comment' => 'protect comment',
183 'namespace' => NS_MAIN
,
184 'title' => 'ProtectPage',
186 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
187 '5:bool:cascade' => false,
192 'expiry' => 'infinity',
198 'expiry' => 'infinity',
205 'text' => 'User changed protection level for ProtectPage ' .
206 '[Edit=Allow only administrators] ' .
207 '(indefinite) [Move=Allow only administrators] (indefinite)',
209 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
215 'expiry' => 'infinite',
221 'expiry' => 'infinite',
229 // Current format with cascade
233 'action' => 'modify',
234 'comment' => 'protect comment',
235 'namespace' => NS_MAIN
,
236 'title' => 'ProtectPage',
238 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
239 '5:bool:cascade' => true,
244 'expiry' => 'infinity',
250 'expiry' => 'infinity',
257 'text' => 'User changed protection level for ProtectPage ' .
258 '[Edit=Allow only administrators] (indefinite) ' .
259 '[Move=Allow only administrators] (indefinite) [cascading]',
261 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
267 'expiry' => 'infinite',
273 'expiry' => 'infinite',
285 'action' => 'modify',
286 'comment' => 'protect comment',
287 'namespace' => NS_MAIN
,
288 'title' => 'ProtectPage',
290 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
296 'text' => 'User changed protection level for ProtectPage ' .
297 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
299 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
305 // Legacy format with cascade
309 'action' => 'modify',
310 'comment' => 'protect comment',
311 'namespace' => NS_MAIN
,
312 'title' => 'ProtectPage',
314 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
320 'text' => 'User changed protection level for ProtectPage ' .
321 '[edit=sysop] (indefinite)[move=sysop] (indefinite) [cascading]',
323 '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',
364 * @dataProvider provideUnprotectLogDatabaseRows
366 public function testUnprotectLogDatabaseRows( $row, $extra ) {
367 $this->doTestLogFormatter( $row, $extra );
371 * Provide different rows from the logging table to test
372 * for backward compatibility.
373 * Do not change the existing data, just add a new database row
375 public static function provideMoveProtLogDatabaseRows() {
381 'action' => 'move_prot',
382 'comment' => 'Move comment',
383 'namespace' => NS_MAIN
,
384 'title' => 'NewPage',
386 '4::oldtitle' => 'OldPage',
390 'text' => 'User moved protection settings from OldPage to NewPage',
393 'oldtitle_title' => 'OldPage',
402 'action' => 'move_prot',
403 'comment' => 'Move comment',
404 'namespace' => NS_MAIN
,
405 'title' => 'NewPage',
412 'text' => 'User moved protection settings from OldPage to NewPage',
415 'oldtitle_title' => 'OldPage',
423 * @dataProvider provideMoveProtLogDatabaseRows
425 public function testMoveProtLogDatabaseRows( $row, $extra ) {
426 $this->doTestLogFormatter( $row, $extra );