rdbms: Rename "memCache" to "memStash" in LBFactory
[mediawiki.git] / tests / phpunit / includes / logging / DeleteLogFormatterTest.php
blob2337899976875655158a4cd1a7f437f8ffdcf062
1 <?php
3 class DeleteLogFormatterTest 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 provideDeleteLogDatabaseRows() {
11 return [
12 // Current format
15 'type' => 'delete',
16 'action' => 'delete',
17 'comment' => 'delete comment',
18 'namespace' => NS_MAIN,
19 'title' => 'Page',
20 'params' => [],
23 'text' => 'User deleted page Page',
24 'api' => [],
28 // Legacy format
31 'type' => 'delete',
32 'action' => 'delete',
33 'comment' => 'delete comment',
34 'namespace' => NS_MAIN,
35 'title' => 'Page',
36 'params' => [],
39 'legacy' => true,
40 'text' => 'User deleted page Page',
41 'api' => [],
47 /**
48 * @dataProvider provideDeleteLogDatabaseRows
50 public function testDeleteLogDatabaseRows( $row, $extra ) {
51 $this->doTestLogFormatter( $row, $extra );
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
59 public static function provideRestoreLogDatabaseRows() {
60 return [
61 // Current format
64 'type' => 'delete',
65 'action' => 'restore',
66 'comment' => 'delete comment',
67 'namespace' => NS_MAIN,
68 'title' => 'Page',
69 'params' => [
70 ':assoc:count' => [
71 'revisions' => 2,
72 'files' => 1,
77 'text' => 'User restored page Page (2 revisions and 1 file)',
78 'api' => [
79 'count' => [
80 'revisions' => 2,
81 'files' => 1,
87 // Legacy format without counts
90 'type' => 'delete',
91 'action' => 'restore',
92 'comment' => 'delete comment',
93 'namespace' => NS_MAIN,
94 'title' => 'Page',
95 'params' => [],
98 'text' => 'User restored page Page',
99 'api' => [],
103 // Legacy format
106 'type' => 'delete',
107 'action' => 'restore',
108 'comment' => 'delete comment',
109 'namespace' => NS_MAIN,
110 'title' => 'Page',
111 'params' => [],
114 'legacy' => true,
115 'text' => 'User restored page Page',
116 'api' => [],
123 * @dataProvider provideRestoreLogDatabaseRows
125 public function testRestoreLogDatabaseRows( $row, $extra ) {
126 $this->doTestLogFormatter( $row, $extra );
130 * Provide different rows from the logging table to test
131 * for backward compatibility.
132 * Do not change the existing data, just add a new database row
134 public static function provideRevisionLogDatabaseRows() {
135 return [
136 // Current format
139 'type' => 'delete',
140 'action' => 'revision',
141 'comment' => 'delete comment',
142 'namespace' => NS_MAIN,
143 'title' => 'Page',
144 'params' => [
145 '4::type' => 'archive',
146 '5::ids' => [ '1', '3', '4' ],
147 '6::ofield' => '1',
148 '7::nfield' => '2',
152 'text' => 'User changed visibility of 3 revisions on page Page: edit summary '
153 . 'hidden and content unhidden',
154 'api' => [
155 'type' => 'archive',
156 'ids' => [ '1', '3', '4' ],
157 'old' => [
158 'bitmask' => 1,
159 'content' => true,
160 'comment' => false,
161 'user' => false,
162 'restricted' => false,
164 'new' => [
165 'bitmask' => 2,
166 'content' => false,
167 'comment' => true,
168 'user' => false,
169 'restricted' => false,
175 // Legacy format
178 'type' => 'delete',
179 'action' => 'revision',
180 'comment' => 'delete comment',
181 'namespace' => NS_MAIN,
182 'title' => 'Page',
183 'params' => [
184 'archive',
185 '1,3,4',
186 'ofield=1',
187 'nfield=2',
191 'legacy' => true,
192 'text' => 'User changed visibility of 3 revisions on page Page: edit summary '
193 . 'hidden and content unhidden',
194 'api' => [
195 'type' => 'archive',
196 'ids' => [ '1', '3', '4' ],
197 'old' => [
198 'bitmask' => 1,
199 'content' => true,
200 'comment' => false,
201 'user' => false,
202 'restricted' => false,
204 'new' => [
205 'bitmask' => 2,
206 'content' => false,
207 'comment' => true,
208 'user' => false,
209 'restricted' => false,
218 * @dataProvider provideRevisionLogDatabaseRows
220 public function testRevisionLogDatabaseRows( $row, $extra ) {
221 $this->doTestLogFormatter( $row, $extra );
225 * Provide different rows from the logging table to test
226 * for backward compatibility.
227 * Do not change the existing data, just add a new database row
229 public static function provideEventLogDatabaseRows() {
230 return [
231 // Current format
234 'type' => 'delete',
235 'action' => 'event',
236 'comment' => 'delete comment',
237 'namespace' => NS_MAIN,
238 'title' => 'Page',
239 'params' => [
240 '4::ids' => [ '1', '3', '4' ],
241 '5::ofield' => '1',
242 '6::nfield' => '2',
246 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
247 . 'and content unhidden',
248 'api' => [
249 'type' => 'logging',
250 'ids' => [ '1', '3', '4' ],
251 'old' => [
252 'bitmask' => 1,
253 'content' => true,
254 'comment' => false,
255 'user' => false,
256 'restricted' => false,
258 'new' => [
259 'bitmask' => 2,
260 'content' => false,
261 'comment' => true,
262 'user' => false,
263 'restricted' => false,
269 // Legacy format
272 'type' => 'delete',
273 'action' => 'event',
274 'comment' => 'delete comment',
275 'namespace' => NS_MAIN,
276 'title' => 'Page',
277 'params' => [
278 '1,3,4',
279 'ofield=1',
280 'nfield=2',
284 'legacy' => true,
285 'text' => 'User changed visibility of 3 log events on Page: edit summary hidden '
286 . 'and content unhidden',
287 'api' => [
288 'type' => 'logging',
289 'ids' => [ '1', '3', '4' ],
290 'old' => [
291 'bitmask' => 1,
292 'content' => true,
293 'comment' => false,
294 'user' => false,
295 'restricted' => false,
297 'new' => [
298 'bitmask' => 2,
299 'content' => false,
300 'comment' => true,
301 'user' => false,
302 'restricted' => false,
311 * @dataProvider provideEventLogDatabaseRows
313 public function testEventLogDatabaseRows( $row, $extra ) {
314 $this->doTestLogFormatter( $row, $extra );
318 * Provide different rows from the logging table to test
319 * for backward compatibility.
320 * Do not change the existing data, just add a new database row
322 public static function provideSuppressRevisionLogDatabaseRows() {
323 return [
324 // Current format
327 'type' => 'suppress',
328 'action' => 'revision',
329 'comment' => 'Suppress comment',
330 'namespace' => NS_MAIN,
331 'title' => 'Page',
332 'params' => [
333 '4::type' => 'archive',
334 '5::ids' => [ '1', '3', '4' ],
335 '6::ofield' => '1',
336 '7::nfield' => '10',
340 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
341 . 'summary hidden, content unhidden and applied restrictions to administrators',
342 'api' => [
343 'type' => 'archive',
344 'ids' => [ '1', '3', '4' ],
345 'old' => [
346 'bitmask' => 1,
347 'content' => true,
348 'comment' => false,
349 'user' => false,
350 'restricted' => false,
352 'new' => [
353 'bitmask' => 10,
354 'content' => false,
355 'comment' => true,
356 'user' => false,
357 'restricted' => true,
363 // Legacy format
366 'type' => 'suppress',
367 'action' => 'revision',
368 'comment' => 'Suppress comment',
369 'namespace' => NS_MAIN,
370 'title' => 'Page',
371 'params' => [
372 'archive',
373 '1,3,4',
374 'ofield=1',
375 'nfield=10',
379 'legacy' => true,
380 'text' => 'User secretly changed visibility of 3 revisions on page Page: edit '
381 . 'summary hidden, content unhidden and applied restrictions to administrators',
382 'api' => [
383 'type' => 'archive',
384 'ids' => [ '1', '3', '4' ],
385 'old' => [
386 'bitmask' => 1,
387 'content' => true,
388 'comment' => false,
389 'user' => false,
390 'restricted' => false,
392 'new' => [
393 'bitmask' => 10,
394 'content' => false,
395 'comment' => true,
396 'user' => false,
397 'restricted' => true,
406 * @dataProvider provideSuppressRevisionLogDatabaseRows
408 public function testSuppressRevisionLogDatabaseRows( $row, $extra ) {
409 $this->doTestLogFormatter( $row, $extra );
413 * Provide different rows from the logging table to test
414 * for backward compatibility.
415 * Do not change the existing data, just add a new database row
417 public static function provideSuppressEventLogDatabaseRows() {
418 return [
419 // Current format
422 'type' => 'suppress',
423 'action' => 'event',
424 'comment' => 'Suppress comment',
425 'namespace' => NS_MAIN,
426 'title' => 'Page',
427 'params' => [
428 '4::ids' => [ '1', '3', '4' ],
429 '5::ofield' => '1',
430 '6::nfield' => '10',
434 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
435 . 'summary hidden, content unhidden and applied restrictions to administrators',
436 'api' => [
437 'type' => 'logging',
438 'ids' => [ '1', '3', '4' ],
439 'old' => [
440 'bitmask' => 1,
441 'content' => true,
442 'comment' => false,
443 'user' => false,
444 'restricted' => false,
446 'new' => [
447 'bitmask' => 10,
448 'content' => false,
449 'comment' => true,
450 'user' => false,
451 'restricted' => true,
457 // Legacy format
460 'type' => 'suppress',
461 'action' => 'event',
462 'comment' => 'Suppress comment',
463 'namespace' => NS_MAIN,
464 'title' => 'Page',
465 'params' => [
466 '1,3,4',
467 'ofield=1',
468 'nfield=10',
472 'legacy' => true,
473 'text' => 'User secretly changed visibility of 3 log events on Page: edit '
474 . 'summary hidden, content unhidden and applied restrictions to administrators',
475 'api' => [
476 'type' => 'logging',
477 'ids' => [ '1', '3', '4' ],
478 'old' => [
479 'bitmask' => 1,
480 'content' => true,
481 'comment' => false,
482 'user' => false,
483 'restricted' => false,
485 'new' => [
486 'bitmask' => 10,
487 'content' => false,
488 'comment' => true,
489 'user' => false,
490 'restricted' => true,
499 * @dataProvider provideSuppressEventLogDatabaseRows
501 public function testSuppressEventLogDatabaseRows( $row, $extra ) {
502 $this->doTestLogFormatter( $row, $extra );
506 * Provide different rows from the logging table to test
507 * for backward compatibility.
508 * Do not change the existing data, just add a new database row
510 public static function provideSuppressDeleteLogDatabaseRows() {
511 return [
512 // Current format
515 'type' => 'suppress',
516 'action' => 'delete',
517 'comment' => 'delete comment',
518 'namespace' => NS_MAIN,
519 'title' => 'Page',
520 'params' => [],
523 'text' => 'User suppressed page Page',
524 'api' => [],
528 // Legacy format
531 'type' => 'suppress',
532 'action' => 'delete',
533 'comment' => 'delete comment',
534 'namespace' => NS_MAIN,
535 'title' => 'Page',
536 'params' => [],
539 'legacy' => true,
540 'text' => 'User suppressed page Page',
541 'api' => [],
548 * @dataProvider provideSuppressDeleteLogDatabaseRows
550 public function testSuppressDeleteLogDatabaseRows( $row, $extra ) {
551 $this->doTestLogFormatter( $row, $extra );