MediaWiki  1.28.0
DeleteLogFormatterTest.php
Go to the documentation of this file.
1 <?php
2 
4 
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 
50  public function testDeleteLogDatabaseRows( $row, $extra ) {
51  $this->doTestLogFormatter( $row, $extra );
52  }
53 
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 
99  public function testRestoreLogDatabaseRows( $row, $extra ) {
100  $this->doTestLogFormatter( $row, $extra );
101  }
102 
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 
194  public function testRevisionLogDatabaseRows( $row, $extra ) {
195  $this->doTestLogFormatter( $row, $extra );
196  }
197 
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 
287  public function testEventLogDatabaseRows( $row, $extra ) {
288  $this->doTestLogFormatter( $row, $extra );
289  }
290 
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 
382  public function testSuppressRevisionLogDatabaseRows( $row, $extra ) {
383  $this->doTestLogFormatter( $row, $extra );
384  }
385 
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 
475  public function testSuppressEventLogDatabaseRows( $row, $extra ) {
476  $this->doTestLogFormatter( $row, $extra );
477  }
478 
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 
524  public function testSuppressDeleteLogDatabaseRows( $row, $extra ) {
525  $this->doTestLogFormatter( $row, $extra );
526  }
527 }
const NS_MAIN
Definition: Defines.php:56
static provideRestoreLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
static provideRevisionLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
static provideSuppressRevisionLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
testSuppressDeleteLogDatabaseRows($row, $extra)
provideSuppressDeleteLogDatabaseRows
static provideDeleteLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
testEventLogDatabaseRows($row, $extra)
provideEventLogDatabaseRows
static provideSuppressDeleteLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
testDeleteLogDatabaseRows($row, $extra)
provideDeleteLogDatabaseRows
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
doTestLogFormatter($row, $extra)
testSuppressRevisionLogDatabaseRows($row, $extra)
provideSuppressRevisionLogDatabaseRows
testRestoreLogDatabaseRows($row, $extra)
provideRestoreLogDatabaseRows
testRevisionLogDatabaseRows($row, $extra)
provideRevisionLogDatabaseRows
static provideSuppressEventLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
testSuppressEventLogDatabaseRows($row, $extra)
provideSuppressEventLogDatabaseRows
static provideEventLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...