MediaWiki  1.28.1
ProtectLogFormatterTest.php
Go to the documentation of this file.
1 <?php
2 
4 
10  public static function provideProtectLogDatabaseRows() {
11  return [
12  // Current format
13  [
14  [
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' => [
24  [
25  'type' => 'edit',
26  'level' => 'sysop',
27  'expiry' => 'infinity',
28  'cascade' => false,
29  ],
30  [
31  'type' => 'move',
32  'level' => 'sysop',
33  'expiry' => 'infinity',
34  'cascade' => false,
35  ],
36  ],
37  ],
38  ],
39  [
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' => [
46  [
47  'type' => 'edit',
48  'level' => 'sysop',
49  'expiry' => 'infinite',
50  'cascade' => false,
51  ],
52  [
53  'type' => 'move',
54  'level' => 'sysop',
55  'expiry' => 'infinite',
56  'cascade' => false,
57  ],
58  ],
59  ],
60  ],
61  ],
62 
63  // Current format with cascade
64  [
65  [
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' => [
75  [
76  'type' => 'edit',
77  'level' => 'sysop',
78  'expiry' => 'infinity',
79  'cascade' => true,
80  ],
81  [
82  'type' => 'move',
83  'level' => 'sysop',
84  'expiry' => 'infinity',
85  'cascade' => false,
86  ],
87  ],
88  ],
89  ],
90  [
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' => [
97  [
98  'type' => 'edit',
99  'level' => 'sysop',
100  'expiry' => 'infinite',
101  'cascade' => true,
102  ],
103  [
104  'type' => 'move',
105  'level' => 'sysop',
106  'expiry' => 'infinite',
107  'cascade' => false,
108  ],
109  ],
110  ],
111  ],
112  ],
113 
114  // Legacy format
115  [
116  [
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)',
124  '',
125  ],
126  ],
127  [
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,
133  ],
134  ],
135  ],
136 
137  // Legacy format with cascade
138  [
139  [
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',
148  ],
149  ],
150  [
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,
157  ],
158  ],
159  ],
160  ];
161  }
162 
166  public function testProtectLogDatabaseRows( $row, $extra ) {
167  $this->doTestLogFormatter( $row, $extra );
168  }
169 
175  public static function provideModifyLogDatabaseRows() {
176  return [
177  // Current format
178  [
179  [
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' => [
189  [
190  'type' => 'edit',
191  'level' => 'sysop',
192  'expiry' => 'infinity',
193  'cascade' => false,
194  ],
195  [
196  'type' => 'move',
197  'level' => 'sysop',
198  'expiry' => 'infinity',
199  'cascade' => false,
200  ],
201  ],
202  ],
203  ],
204  [
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' => [
212  [
213  'type' => 'edit',
214  'level' => 'sysop',
215  'expiry' => 'infinite',
216  'cascade' => false,
217  ],
218  [
219  'type' => 'move',
220  'level' => 'sysop',
221  'expiry' => 'infinite',
222  'cascade' => false,
223  ],
224  ],
225  ],
226  ],
227  ],
228 
229  // Current format with cascade
230  [
231  [
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' => [
241  [
242  'type' => 'edit',
243  'level' => 'sysop',
244  'expiry' => 'infinity',
245  'cascade' => true,
246  ],
247  [
248  'type' => 'move',
249  'level' => 'sysop',
250  'expiry' => 'infinity',
251  'cascade' => false,
252  ],
253  ],
254  ],
255  ],
256  [
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' => [
264  [
265  'type' => 'edit',
266  'level' => 'sysop',
267  'expiry' => 'infinite',
268  'cascade' => true,
269  ],
270  [
271  'type' => 'move',
272  'level' => 'sysop',
273  'expiry' => 'infinite',
274  'cascade' => false,
275  ],
276  ],
277  ],
278  ],
279  ],
280 
281  // Legacy format
282  [
283  [
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)',
291  '',
292  ],
293  ],
294  [
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,
301  ],
302  ],
303  ],
304 
305  // Legacy format with cascade
306  [
307  [
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',
316  ],
317  ],
318  [
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,
325  ],
326  ],
327  ],
328  ];
329  }
330 
334  public function testModifyLogDatabaseRows( $row, $extra ) {
335  $this->doTestLogFormatter( $row, $extra );
336  }
337 
343  public static function provideUnprotectLogDatabaseRows() {
344  return [
345  // Current format
346  [
347  [
348  'type' => 'protect',
349  'action' => 'unprotect',
350  'comment' => 'unprotect comment',
351  'namespace' => NS_MAIN,
352  'title' => 'ProtectPage',
353  'params' => [],
354  ],
355  [
356  'text' => 'User removed protection from ProtectPage',
357  'api' => [],
358  ],
359  ],
360  ];
361  }
362 
366  public function testUnprotectLogDatabaseRows( $row, $extra ) {
367  $this->doTestLogFormatter( $row, $extra );
368  }
369 
375  public static function provideMoveProtLogDatabaseRows() {
376  return [
377  // Current format
378  [
379  [
380  'type' => 'protect',
381  'action' => 'move_prot',
382  'comment' => 'Move comment',
383  'namespace' => NS_MAIN,
384  'title' => 'NewPage',
385  'params' => [
386  '4::oldtitle' => 'OldPage',
387  ],
388  ],
389  [
390  'text' => 'User moved protection settings from OldPage to NewPage',
391  'api' => [
392  'oldtitle_ns' => 0,
393  'oldtitle_title' => 'OldPage',
394  ],
395  ],
396  ],
397 
398  // Legacy format
399  [
400  [
401  'type' => 'protect',
402  'action' => 'move_prot',
403  'comment' => 'Move comment',
404  'namespace' => NS_MAIN,
405  'title' => 'NewPage',
406  'params' => [
407  'OldPage',
408  ],
409  ],
410  [
411  'legacy' => true,
412  'text' => 'User moved protection settings from OldPage to NewPage',
413  'api' => [
414  'oldtitle_ns' => 0,
415  'oldtitle_title' => 'OldPage',
416  ],
417  ],
418  ],
419  ];
420  }
421 
425  public function testMoveProtLogDatabaseRows( $row, $extra ) {
426  $this->doTestLogFormatter( $row, $extra );
427  }
428 }
const NS_MAIN
Definition: Defines.php:56
testProtectLogDatabaseRows($row, $extra)
provideProtectLogDatabaseRows
static provideProtectLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
static provideUnprotectLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
testUnprotectLogDatabaseRows($row, $extra)
provideUnprotectLogDatabaseRows
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
static provideMoveProtLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
doTestLogFormatter($row, $extra)
testModifyLogDatabaseRows($row, $extra)
provideModifyLogDatabaseRows
testMoveProtLogDatabaseRows($row, $extra)
provideMoveProtLogDatabaseRows
static provideModifyLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...