4 * @covers ProtectLogFormatter
6 class ProtectLogFormatterTest
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 provideProtectLogDatabaseRows() {
19 'action' => 'protect',
20 'comment' => 'protect comment',
21 'namespace' => NS_MAIN
,
22 'title' => 'ProtectPage',
24 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
25 '5:bool:cascade' => false,
30 'expiry' => 'infinity',
36 'expiry' => 'infinity',
43 'text' => 'User protected ProtectPage [Edit=Allow only administrators] ' .
44 '(indefinite) [Move=Allow only administrators] (indefinite)',
46 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
52 'expiry' => 'infinite',
58 'expiry' => 'infinite',
66 // Current format with cascade
70 'action' => 'protect',
71 'comment' => 'protect comment',
72 'namespace' => NS_MAIN
,
73 'title' => 'ProtectPage',
75 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
76 '5:bool:cascade' => true,
81 'expiry' => 'infinity',
87 'expiry' => 'infinity',
94 'text' => 'User protected ProtectPage [Edit=Allow only administrators] ' .
95 '(indefinite) [Move=Allow only administrators] (indefinite) [cascading]',
97 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
103 'expiry' => 'infinite',
109 'expiry' => 'infinite',
121 'action' => 'protect',
122 'comment' => 'protect comment',
123 'namespace' => NS_MAIN
,
124 'title' => 'ProtectPage',
126 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
132 'text' => 'User protected ProtectPage [edit=sysop] (indefinite)[move=sysop] (indefinite)',
134 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
140 // Legacy format with cascade
144 'action' => 'protect',
145 'comment' => 'protect comment',
146 'namespace' => NS_MAIN
,
147 'title' => 'ProtectPage',
149 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
155 'text' => 'User protected ProtectPage [edit=sysop] ' .
156 '(indefinite)[move=sysop] (indefinite) [cascading]',
158 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
167 * @dataProvider provideProtectLogDatabaseRows
169 public function testProtectLogDatabaseRows( $row, $extra ) {
170 $this->doTestLogFormatter( $row, $extra );
174 * Provide different rows from the logging table to test
175 * for backward compatibility.
176 * Do not change the existing data, just add a new database row
178 public static function provideModifyLogDatabaseRows() {
184 'action' => 'modify',
185 'comment' => 'protect comment',
186 'namespace' => NS_MAIN
,
187 'title' => 'ProtectPage',
189 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
190 '5:bool:cascade' => false,
195 'expiry' => 'infinity',
201 'expiry' => 'infinity',
208 'text' => 'User changed protection level for ProtectPage ' .
209 '[Edit=Allow only administrators] ' .
210 '(indefinite) [Move=Allow only administrators] (indefinite)',
212 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
218 'expiry' => 'infinite',
224 'expiry' => 'infinite',
232 // Current format with cascade
236 'action' => 'modify',
237 'comment' => 'protect comment',
238 'namespace' => NS_MAIN
,
239 'title' => 'ProtectPage',
241 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
242 '5:bool:cascade' => true,
247 'expiry' => 'infinity',
253 'expiry' => 'infinity',
260 'text' => 'User changed protection level for ProtectPage ' .
261 '[Edit=Allow only administrators] (indefinite) ' .
262 '[Move=Allow only administrators] (indefinite) [cascading]',
264 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
270 'expiry' => 'infinite',
276 'expiry' => 'infinite',
288 'action' => 'modify',
289 'comment' => 'protect comment',
290 'namespace' => NS_MAIN
,
291 'title' => 'ProtectPage',
293 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
299 'text' => 'User changed protection level for ProtectPage ' .
300 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
302 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
308 // Legacy format with cascade
312 'action' => 'modify',
313 'comment' => 'protect comment',
314 'namespace' => NS_MAIN
,
315 'title' => 'ProtectPage',
317 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
323 'text' => 'User changed protection level for ProtectPage ' .
324 '[edit=sysop] (indefinite)[move=sysop] (indefinite) [cascading]',
326 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
335 * @dataProvider provideModifyLogDatabaseRows
337 public function testModifyLogDatabaseRows( $row, $extra ) {
338 $this->doTestLogFormatter( $row, $extra );
342 * Provide different rows from the logging table to test
343 * for backward compatibility.
344 * Do not change the existing data, just add a new database row
346 public static function provideUnprotectLogDatabaseRows() {
352 'action' => 'unprotect',
353 'comment' => 'unprotect comment',
354 'namespace' => NS_MAIN
,
355 'title' => 'ProtectPage',
359 '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 );