Move ResultWrapper subclasses to Rdbms
[mediawiki.git] / tests / phpunit / includes / logging / ProtectLogFormatterTest.php
blob1fa7fc247092998ff88771cae5bb3d0ddf58c124
1 <?php
3 class ProtectLogFormatterTest extends LogFormatterTestCase {
5 /**
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
9 */
10 public static function provideProtectLogDatabaseRows() {
11 return [
12 // Current format
15 'type' => 'protect',
16 'action' => 'protect',
17 'comment' => 'protect comment',
18 'namespace' => NS_MAIN,
19 'title' => 'ProtectPage',
20 'params' => [
21 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
22 '5:bool:cascade' => false,
23 'details' => [
25 'type' => 'edit',
26 'level' => 'sysop',
27 'expiry' => 'infinity',
28 'cascade' => false,
31 'type' => 'move',
32 'level' => 'sysop',
33 'expiry' => 'infinity',
34 'cascade' => false,
40 'text' => 'User protected ProtectPage [Edit=Allow only administrators] ' .
41 '(indefinite) [Move=Allow only administrators] (indefinite)',
42 'api' => [
43 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
44 'cascade' => false,
45 'details' => [
47 'type' => 'edit',
48 'level' => 'sysop',
49 'expiry' => 'infinite',
50 'cascade' => false,
53 'type' => 'move',
54 'level' => 'sysop',
55 'expiry' => 'infinite',
56 'cascade' => false,
63 // Current format with cascade
66 'type' => 'protect',
67 'action' => 'protect',
68 'comment' => 'protect comment',
69 'namespace' => NS_MAIN,
70 'title' => 'ProtectPage',
71 'params' => [
72 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
73 '5:bool:cascade' => true,
74 'details' => [
76 'type' => 'edit',
77 'level' => 'sysop',
78 'expiry' => 'infinity',
79 'cascade' => true,
82 'type' => 'move',
83 'level' => 'sysop',
84 'expiry' => 'infinity',
85 'cascade' => false,
91 'text' => 'User protected ProtectPage [Edit=Allow only administrators] ' .
92 '(indefinite) [Move=Allow only administrators] (indefinite) [cascading]',
93 'api' => [
94 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
95 'cascade' => true,
96 'details' => [
98 'type' => 'edit',
99 'level' => 'sysop',
100 'expiry' => 'infinite',
101 'cascade' => true,
104 'type' => 'move',
105 'level' => 'sysop',
106 'expiry' => 'infinite',
107 'cascade' => false,
114 // Legacy format
117 'type' => 'protect',
118 'action' => 'protect',
119 'comment' => 'protect comment',
120 'namespace' => NS_MAIN,
121 'title' => 'ProtectPage',
122 'params' => [
123 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
128 'legacy' => true,
129 'text' => 'User protected ProtectPage [edit=sysop] (indefinite)[move=sysop] (indefinite)',
130 'api' => [
131 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
132 'cascade' => false,
137 // Legacy format with cascade
140 'type' => 'protect',
141 'action' => 'protect',
142 'comment' => 'protect comment',
143 'namespace' => NS_MAIN,
144 'title' => 'ProtectPage',
145 'params' => [
146 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
147 'cascade',
151 'legacy' => true,
152 'text' => 'User protected ProtectPage [edit=sysop] ' .
153 '(indefinite)[move=sysop] (indefinite) [cascading]',
154 'api' => [
155 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
156 'cascade' => true,
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() {
176 return [
177 // Current format
180 'type' => 'protect',
181 'action' => 'modify',
182 'comment' => 'protect comment',
183 'namespace' => NS_MAIN,
184 'title' => 'ProtectPage',
185 'params' => [
186 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
187 '5:bool:cascade' => false,
188 'details' => [
190 'type' => 'edit',
191 'level' => 'sysop',
192 'expiry' => 'infinity',
193 'cascade' => false,
196 'type' => 'move',
197 'level' => 'sysop',
198 'expiry' => 'infinity',
199 'cascade' => false,
205 'text' => 'User changed protection level for ProtectPage ' .
206 '[Edit=Allow only administrators] ' .
207 '(indefinite) [Move=Allow only administrators] (indefinite)',
208 'api' => [
209 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
210 'cascade' => false,
211 'details' => [
213 'type' => 'edit',
214 'level' => 'sysop',
215 'expiry' => 'infinite',
216 'cascade' => false,
219 'type' => 'move',
220 'level' => 'sysop',
221 'expiry' => 'infinite',
222 'cascade' => false,
229 // Current format with cascade
232 'type' => 'protect',
233 'action' => 'modify',
234 'comment' => 'protect comment',
235 'namespace' => NS_MAIN,
236 'title' => 'ProtectPage',
237 'params' => [
238 '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
239 '5:bool:cascade' => true,
240 'details' => [
242 'type' => 'edit',
243 'level' => 'sysop',
244 'expiry' => 'infinity',
245 'cascade' => true,
248 'type' => 'move',
249 'level' => 'sysop',
250 'expiry' => 'infinity',
251 'cascade' => false,
257 'text' => 'User changed protection level for ProtectPage ' .
258 '[Edit=Allow only administrators] (indefinite) ' .
259 '[Move=Allow only administrators] (indefinite) [cascading]',
260 'api' => [
261 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
262 'cascade' => true,
263 'details' => [
265 'type' => 'edit',
266 'level' => 'sysop',
267 'expiry' => 'infinite',
268 'cascade' => true,
271 'type' => 'move',
272 'level' => 'sysop',
273 'expiry' => 'infinite',
274 'cascade' => false,
281 // Legacy format
284 'type' => 'protect',
285 'action' => 'modify',
286 'comment' => 'protect comment',
287 'namespace' => NS_MAIN,
288 'title' => 'ProtectPage',
289 'params' => [
290 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
295 'legacy' => true,
296 'text' => 'User changed protection level for ProtectPage ' .
297 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
298 'api' => [
299 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
300 'cascade' => false,
305 // Legacy format with cascade
308 'type' => 'protect',
309 'action' => 'modify',
310 'comment' => 'protect comment',
311 'namespace' => NS_MAIN,
312 'title' => 'ProtectPage',
313 'params' => [
314 '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
315 'cascade',
319 'legacy' => true,
320 'text' => 'User changed protection level for ProtectPage ' .
321 '[edit=sysop] (indefinite)[move=sysop] (indefinite) [cascading]',
322 'api' => [
323 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
324 'cascade' => true,
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() {
344 return [
345 // Current format
348 'type' => 'protect',
349 'action' => 'unprotect',
350 'comment' => 'unprotect comment',
351 'namespace' => NS_MAIN,
352 'title' => 'ProtectPage',
353 'params' => [],
356 'text' => 'User removed protection from ProtectPage',
357 'api' => [],
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() {
376 return [
377 // Current format
380 'type' => 'protect',
381 'action' => 'move_prot',
382 'comment' => 'Move comment',
383 'namespace' => NS_MAIN,
384 'title' => 'NewPage',
385 'params' => [
386 '4::oldtitle' => 'OldPage',
390 'text' => 'User moved protection settings from OldPage to NewPage',
391 'api' => [
392 'oldtitle_ns' => 0,
393 'oldtitle_title' => 'OldPage',
398 // Legacy format
401 'type' => 'protect',
402 'action' => 'move_prot',
403 'comment' => 'Move comment',
404 'namespace' => NS_MAIN,
405 'title' => 'NewPage',
406 'params' => [
407 'OldPage',
411 'legacy' => true,
412 'text' => 'User moved protection settings from OldPage to NewPage',
413 'api' => [
414 'oldtitle_ns' => 0,
415 'oldtitle_title' => 'OldPage',
423 * @dataProvider provideMoveProtLogDatabaseRows
425 public function testMoveProtLogDatabaseRows( $row, $extra ) {
426 $this->doTestLogFormatter( $row, $extra );