Merge "Fix escaping for MSSQL LIKE queries."
[lhc/web/wiklou.git] / tests / phpunit / includes / logging / DeleteLogFormatterTest.php
1 <?php
2
3 class DeleteLogFormatterTest extends LogFormatterTestCase {
4
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 provideDeleteLogDatabaseRows() {
11 return [
12 // Current format
13 [
14 [
15 'type' => 'delete',
16 'action' => 'delete',
17 'comment' => 'delete comment',
18 'namespace' => NS_MAIN,
19 'title' => 'Page',
20 'params' => [],
21 ],
22 [
23 'text' => 'User deleted page Page',
24 'api' => [],
25 ],
26 ],
27
28 // Legacy format
29 [
30 [
31 'type' => 'delete',
32 'action' => 'delete',
33 'comment' => 'delete comment',
34 'namespace' => NS_MAIN,
35 'title' => 'Page',
36 'params' => [],
37 ],
38 [
39 'legacy' => true,
40 'text' => 'User deleted page Page',
41 'api' => [],
42 ],
43 ],
44 ];
45 }
46
47 /**
48 * @dataProvider provideDeleteLogDatabaseRows
49 */
50 public function testDeleteLogDatabaseRows( $row, $extra ) {
51 $this->doTestLogFormatter( $row, $extra );
52 }
53
54 /**
55 * Provide different rows from the logging table to test
56 * for backward compatibility.
57 * Do not change the existing data, just add a new database row
58 */
59 public static function provideRestoreLogDatabaseRows() {
60 return [
61 // Current format
62 [
63 [
64 'type' => 'delete',
65 'action' => 'restore',
66 'comment' => 'delete comment',
67 'namespace' => NS_MAIN,
68 'title' => 'Page',
69 'params' => [],
70 ],
71 [
72 'text' => 'User restored page Page',
73 'api' => [],
74 ],
75 ],
76
77 // Legacy format
78 [
79 [
80 'type' => 'delete',
81 'action' => 'restore',
82 'comment' => 'delete comment',
83 'namespace' => NS_MAIN,
84 'title' => 'Page',
85 'params' => [],
86 ],
87 [
88 'legacy' => true,
89 'text' => 'User restored page Page',
90 'api' => [],
91 ],
92 ],
93 ];
94 }
95
96 /**
97 * @dataProvider provideRestoreLogDatabaseRows
98 */
99 public function testRestoreLogDatabaseRows( $row, $extra ) {
100 $this->doTestLogFormatter( $row, $extra );
101 }
102
103 /**
104 * Provide different rows from the logging table to test
105 * for backward compatibility.
106 * Do not change the existing data, just add a new database row
107 */
108 public static function provideRevisionLogDatabaseRows() {
109 return [
110 // Current format
111 [
112 [
113 'type' => 'delete',
114 'action' => 'revision',
115 'comment' => 'delete comment',
116 'namespace' => NS_MAIN,
117 'title' => 'Page',
118 'params' => [
119 '4::type' => 'archive',
120 '5::ids' => [ '1', '3', '4' ],
121 '6::ofield' => '1',
122 '7::nfield' => '2',
123 ],
124 ],
125 [
126 'text' => 'User changed visibility of 3 revisions on page Page: edit summary '
127 . 'hidden and content unhidden',
128 'api' => [
129 'type' => 'archive',
130 'ids' => [ '1', '3', '4' ],
131 'old' => [
132 'bitmask' => 1,
133 'content' => true,
134 'comment' => false,
135 'user' => false,
136 'restricted' => false,
137 ],
138 'new' => [
139 'bitmask' => 2,
140 'content' => false,
141 'comment' => true,
142 'user' => false,
143 'restricted' => false,
144 ],
145 ],
146 ],
147 ],
148
149 // Legacy format
150 [
151 [
152 'type' => 'delete',
153 'action' => 'revision',
154 'comment' => 'delete comment',
155 'namespace' => NS_MAIN,
156 'title' => 'Page',
157 'params' => [
158 'archive',
159 '1,3,4',
160 'ofield=1',
161 'nfield=2',
162 ],
163 ],
164 [
165 'legacy' => true,
166 'text' => 'User changed visibility of 3 revisions on page Page: edit summary '
167 . 'hidden and content unhidden',
168 'api' => [
169 'type' => 'archive',
170 'ids' => [ '1', '3', '4' ],
171 'old' => [
172 'bitmask' => 1,
173 'content' => true,
174 'comment' => false,
175 'user' => false,
176 'restricted' => false,
177 ],
178 'new' => [
179 'bitmask' => 2,
180 'content' => false,
181 'comment' => true,
182 'user' => false,
183 'restricted' => false,
184 ],
185 ],
186 ],
187 ],
188 ];
189 }
190
191 /**
192 * @dataProvider provideRevisionLogDatabaseRows
193 */
194 public function testRevisionLogDatabaseRows( $row, $extra ) {
195 $this->doTestLogFormatter( $row, $extra );
196 }
197
198 /**
199 * Provide different rows from the logging table to test
200 * for backward compatibility.
201 * Do not change the existing data, just add a new database row
202 */
203 public static function provideEventLogDatabaseRows() {
204 return [
205 // Current format
206 [
207 [
208 'type' => 'delete',
209 'action' => 'event',
210 'comment' => 'delete comment',
211 'namespace' => NS_MAIN,
212 'title' => 'Page',
213 'params' => [
214 '4::ids' => [ '1', '3', '4' ],
215 '5::ofield' => '1',
216 '6::nfield' => '2',
217 ],
218 ],
219 [
220 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
221 . 'and content unhidden',
222 'api' => [
223 'type' => 'logging',
224 'ids' => [ '1', '3', '4' ],
225 'old' => [
226 'bitmask' => 1,
227 'content' => true,
228 'comment' => false,
229 'user' => false,
230 'restricted' => false,
231 ],
232 'new' => [
233 'bitmask' => 2,
234 'content' => false,
235 'comment' => true,
236 'user' => false,
237 'restricted' => false,
238 ],
239 ],
240 ],
241 ],
242
243 // Legacy format
244 [
245 [
246 'type' => 'delete',
247 'action' => 'event',
248 'comment' => 'delete comment',
249 'namespace' => NS_MAIN,
250 'title' => 'Page',
251 'params' => [
252 '1,3,4',
253 'ofield=1',
254 'nfield=2',
255 ],
256 ],
257 [
258 'legacy' => true,
259 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
260 . 'and content unhidden',
261 'api' => [
262 'type' => 'logging',
263 'ids' => [ '1', '3', '4' ],
264 'old' => [
265 'bitmask' => 1,
266 'content' => true,
267 'comment' => false,
268 'user' => false,
269 'restricted' => false,
270 ],
271 'new' => [
272 'bitmask' => 2,
273 'content' => false,
274 'comment' => true,
275 'user' => false,
276 'restricted' => false,
277 ],
278 ],
279 ],
280 ],
281 ];
282 }
283
284 /**
285 * @dataProvider provideEventLogDatabaseRows
286 */
287 public function testEventLogDatabaseRows( $row, $extra ) {
288 $this->doTestLogFormatter( $row, $extra );
289 }
290
291 /**
292 * Provide different rows from the logging table to test
293 * for backward compatibility.
294 * Do not change the existing data, just add a new database row
295 */
296 public static function provideSuppressRevisionLogDatabaseRows() {
297 return [
298 // Current format
299 [
300 [
301 'type' => 'suppress',
302 'action' => 'revision',
303 'comment' => 'Suppress comment',
304 'namespace' => NS_MAIN,
305 'title' => 'Page',
306 'params' => [
307 '4::type' => 'archive',
308 '5::ids' => [ '1', '3', '4' ],
309 '6::ofield' => '1',
310 '7::nfield' => '10',
311 ],
312 ],
313 [
314 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
315 . 'summary hidden, content unhidden and applied restrictions to administrators',
316 'api' => [
317 'type' => 'archive',
318 'ids' => [ '1', '3', '4' ],
319 'old' => [
320 'bitmask' => 1,
321 'content' => true,
322 'comment' => false,
323 'user' => false,
324 'restricted' => false,
325 ],
326 'new' => [
327 'bitmask' => 10,
328 'content' => false,
329 'comment' => true,
330 'user' => false,
331 'restricted' => true,
332 ],
333 ],
334 ],
335 ],
336
337 // Legacy format
338 [
339 [
340 'type' => 'suppress',
341 'action' => 'revision',
342 'comment' => 'Suppress comment',
343 'namespace' => NS_MAIN,
344 'title' => 'Page',
345 'params' => [
346 'archive',
347 '1,3,4',
348 'ofield=1',
349 'nfield=10',
350 ],
351 ],
352 [
353 'legacy' => true,
354 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
355 . 'summary hidden, content unhidden and applied restrictions to administrators',
356 'api' => [
357 'type' => 'archive',
358 'ids' => [ '1', '3', '4' ],
359 'old' => [
360 'bitmask' => 1,
361 'content' => true,
362 'comment' => false,
363 'user' => false,
364 'restricted' => false,
365 ],
366 'new' => [
367 'bitmask' => 10,
368 'content' => false,
369 'comment' => true,
370 'user' => false,
371 'restricted' => true,
372 ],
373 ],
374 ],
375 ],
376 ];
377 }
378
379 /**
380 * @dataProvider provideSuppressRevisionLogDatabaseRows
381 */
382 public function testSuppressRevisionLogDatabaseRows( $row, $extra ) {
383 $this->doTestLogFormatter( $row, $extra );
384 }
385
386 /**
387 * Provide different rows from the logging table to test
388 * for backward compatibility.
389 * Do not change the existing data, just add a new database row
390 */
391 public static function provideSuppressEventLogDatabaseRows() {
392 return [
393 // Current format
394 [
395 [
396 'type' => 'suppress',
397 'action' => 'event',
398 'comment' => 'Suppress comment',
399 'namespace' => NS_MAIN,
400 'title' => 'Page',
401 'params' => [
402 '4::ids' => [ '1', '3', '4' ],
403 '5::ofield' => '1',
404 '6::nfield' => '10',
405 ],
406 ],
407 [
408 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
409 . 'summary hidden, content unhidden and applied restrictions to administrators',
410 'api' => [
411 'type' => 'logging',
412 'ids' => [ '1', '3', '4' ],
413 'old' => [
414 'bitmask' => 1,
415 'content' => true,
416 'comment' => false,
417 'user' => false,
418 'restricted' => false,
419 ],
420 'new' => [
421 'bitmask' => 10,
422 'content' => false,
423 'comment' => true,
424 'user' => false,
425 'restricted' => true,
426 ],
427 ],
428 ],
429 ],
430
431 // Legacy format
432 [
433 [
434 'type' => 'suppress',
435 'action' => 'event',
436 'comment' => 'Suppress comment',
437 'namespace' => NS_MAIN,
438 'title' => 'Page',
439 'params' => [
440 '1,3,4',
441 'ofield=1',
442 'nfield=10',
443 ],
444 ],
445 [
446 'legacy' => true,
447 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
448 . 'summary hidden, content unhidden and applied restrictions to administrators',
449 'api' => [
450 'type' => 'logging',
451 'ids' => [ '1', '3', '4' ],
452 'old' => [
453 'bitmask' => 1,
454 'content' => true,
455 'comment' => false,
456 'user' => false,
457 'restricted' => false,
458 ],
459 'new' => [
460 'bitmask' => 10,
461 'content' => false,
462 'comment' => true,
463 'user' => false,
464 'restricted' => true,
465 ],
466 ],
467 ],
468 ],
469 ];
470 }
471
472 /**
473 * @dataProvider provideSuppressEventLogDatabaseRows
474 */
475 public function testSuppressEventLogDatabaseRows( $row, $extra ) {
476 $this->doTestLogFormatter( $row, $extra );
477 }
478
479 /**
480 * Provide different rows from the logging table to test
481 * for backward compatibility.
482 * Do not change the existing data, just add a new database row
483 */
484 public static function provideSuppressDeleteLogDatabaseRows() {
485 return [
486 // Current format
487 [
488 [
489 'type' => 'suppress',
490 'action' => 'delete',
491 'comment' => 'delete comment',
492 'namespace' => NS_MAIN,
493 'title' => 'Page',
494 'params' => [],
495 ],
496 [
497 'text' => 'User suppressed page Page',
498 'api' => [],
499 ],
500 ],
501
502 // Legacy format
503 [
504 [
505 'type' => 'suppress',
506 'action' => 'delete',
507 'comment' => 'delete comment',
508 'namespace' => NS_MAIN,
509 'title' => 'Page',
510 'params' => [],
511 ],
512 [
513 'legacy' => true,
514 'text' => 'User suppressed page Page',
515 'api' => [],
516 ],
517 ],
518 ];
519 }
520
521 /**
522 * @dataProvider provideSuppressDeleteLogDatabaseRows
523 */
524 public function testSuppressDeleteLogDatabaseRows( $row, $extra ) {
525 $this->doTestLogFormatter( $row, $extra );
526 }
527 }