MediaWiki  1.28.0
BlockLogFormatterTest.php
Go to the documentation of this file.
1 <?php
2 
4 
10  public static function provideBlockLogDatabaseRows() {
11  return [
12  // Current log format
13  [
14  [
15  'type' => 'block',
16  'action' => 'block',
17  'comment' => 'Block comment',
18  'user' => 0,
19  'user_text' => 'Sysop',
20  'namespace' => NS_USER,
21  'title' => 'Logtestuser',
22  'params' => [
23  '5::duration' => 'infinite',
24  '6::flags' => 'anononly',
25  ],
26  ],
27  [
28  'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
29  . ' (anonymous users only)',
30  'api' => [
31  'duration' => 'infinite',
32  'flags' => [ 'anononly' ],
33  ],
34  ],
35  ],
36 
37  // Old legacy log
38  [
39  [
40  'type' => 'block',
41  'action' => 'block',
42  'comment' => 'Block comment',
43  'user' => 0,
44  'user_text' => 'Sysop',
45  'namespace' => NS_USER,
46  'title' => 'Logtestuser',
47  'params' => [
48  'infinite',
49  'anononly',
50  ],
51  ],
52  [
53  'legacy' => true,
54  'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
55  . ' (anonymous users only)',
56  'api' => [
57  'duration' => 'infinite',
58  'flags' => [ 'anononly' ],
59  ],
60  ],
61  ],
62 
63  // Old legacy log without flag
64  [
65  [
66  'type' => 'block',
67  'action' => 'block',
68  'comment' => 'Block comment',
69  'user' => 0,
70  'user_text' => 'Sysop',
71  'namespace' => NS_USER,
72  'title' => 'Logtestuser',
73  'params' => [
74  'infinite',
75  ],
76  ],
77  [
78  'legacy' => true,
79  'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite',
80  'api' => [
81  'duration' => 'infinite',
82  'flags' => [],
83  ],
84  ],
85  ],
86 
87  // Very old legacy log without duration
88  [
89  [
90  'type' => 'block',
91  'action' => 'block',
92  'comment' => 'Block comment',
93  'user' => 0,
94  'user_text' => 'Sysop',
95  'namespace' => NS_USER,
96  'title' => 'Logtestuser',
97  'params' => [],
98  ],
99  [
100  'legacy' => true,
101  'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite',
102  'api' => [
103  'duration' => 'infinite',
104  'flags' => [],
105  ],
106  ],
107  ],
108  ];
109  }
110 
114  public function testBlockLogDatabaseRows( $row, $extra ) {
115  $this->doTestLogFormatter( $row, $extra );
116  }
117 
123  public static function provideReblockLogDatabaseRows() {
124  return [
125  // Current log format
126  [
127  [
128  'type' => 'block',
129  'action' => 'reblock',
130  'comment' => 'Block comment',
131  'user' => 0,
132  'user_text' => 'Sysop',
133  'namespace' => NS_USER,
134  'title' => 'Logtestuser',
135  'params' => [
136  '5::duration' => 'infinite',
137  '6::flags' => 'anononly',
138  ],
139  ],
140  [
141  'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
142  . ' indefinite (anonymous users only)',
143  'api' => [
144  'duration' => 'infinite',
145  'flags' => [ 'anononly' ],
146  ],
147  ],
148  ],
149 
150  // Old log
151  [
152  [
153  'type' => 'block',
154  'action' => 'reblock',
155  'comment' => 'Block comment',
156  'user' => 0,
157  'user_text' => 'Sysop',
158  'namespace' => NS_USER,
159  'title' => 'Logtestuser',
160  'params' => [
161  'infinite',
162  'anononly',
163  ],
164  ],
165  [
166  'legacy' => true,
167  'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
168  . ' indefinite (anonymous users only)',
169  'api' => [
170  'duration' => 'infinite',
171  'flags' => [ 'anononly' ],
172  ],
173  ],
174  ],
175 
176  // Older log without flag
177  [
178  [
179  'type' => 'block',
180  'action' => 'reblock',
181  'comment' => 'Block comment',
182  'user' => 0,
183  'user_text' => 'Sysop',
184  'namespace' => NS_USER,
185  'title' => 'Logtestuser',
186  'params' => [
187  'infinite',
188  ]
189  ],
190  [
191  'legacy' => true,
192  'text' => 'Sysop changed block settings for Logtestuser with an expiration time of indefinite',
193  'api' => [
194  'duration' => 'infinite',
195  'flags' => [],
196  ],
197  ],
198  ],
199  ];
200  }
201 
205  public function testReblockLogDatabaseRows( $row, $extra ) {
206  $this->doTestLogFormatter( $row, $extra );
207  }
208 
214  public static function provideUnblockLogDatabaseRows() {
215  return [
216  // Current log format
217  [
218  [
219  'type' => 'block',
220  'action' => 'unblock',
221  'comment' => 'Block comment',
222  'user' => 0,
223  'user_text' => 'Sysop',
224  'namespace' => NS_USER,
225  'title' => 'Logtestuser',
226  'params' => [],
227  ],
228  [
229  'text' => 'Sysop unblocked Logtestuser',
230  'api' => [],
231  ],
232  ],
233  ];
234  }
235 
239  public function testUnblockLogDatabaseRows( $row, $extra ) {
240  $this->doTestLogFormatter( $row, $extra );
241  }
242 
248  public static function provideSuppressBlockLogDatabaseRows() {
249  return [
250  // Current log format
251  [
252  [
253  'type' => 'suppress',
254  'action' => 'block',
255  'comment' => 'Block comment',
256  'user' => 0,
257  'user_text' => 'Sysop',
258  'namespace' => NS_USER,
259  'title' => 'Logtestuser',
260  'params' => [
261  '5::duration' => 'infinite',
262  '6::flags' => 'anononly',
263  ],
264  ],
265  [
266  'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
267  . ' (anonymous users only)',
268  'api' => [
269  'duration' => 'infinite',
270  'flags' => [ 'anononly' ],
271  ],
272  ],
273  ],
274 
275  // legacy log
276  [
277  [
278  'type' => 'suppress',
279  'action' => 'block',
280  'comment' => 'Block comment',
281  'user' => 0,
282  'user_text' => 'Sysop',
283  'namespace' => NS_USER,
284  'title' => 'Logtestuser',
285  'params' => [
286  'infinite',
287  'anononly',
288  ],
289  ],
290  [
291  'legacy' => true,
292  'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
293  . ' (anonymous users only)',
294  'api' => [
295  'duration' => 'infinite',
296  'flags' => [ 'anononly' ],
297  ],
298  ],
299  ],
300  ];
301  }
302 
306  public function testSuppressBlockLogDatabaseRows( $row, $extra ) {
307  $this->doTestLogFormatter( $row, $extra );
308  }
309 
315  public static function provideSuppressReblockLogDatabaseRows() {
316  return [
317  // Current log format
318  [
319  [
320  'type' => 'suppress',
321  'action' => 'reblock',
322  'comment' => 'Block comment',
323  'user' => 0,
324  'user_text' => 'Sysop',
325  'namespace' => NS_USER,
326  'title' => 'Logtestuser',
327  'params' => [
328  '5::duration' => 'infinite',
329  '6::flags' => 'anononly',
330  ],
331  ],
332  [
333  'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
334  . ' indefinite (anonymous users only)',
335  'api' => [
336  'duration' => 'infinite',
337  'flags' => [ 'anononly' ],
338  ],
339  ],
340  ],
341 
342  // Legacy format
343  [
344  [
345  'type' => 'suppress',
346  'action' => 'reblock',
347  'comment' => 'Block comment',
348  'user' => 0,
349  'user_text' => 'Sysop',
350  'namespace' => NS_USER,
351  'title' => 'Logtestuser',
352  'params' => [
353  'infinite',
354  'anononly',
355  ],
356  ],
357  [
358  'legacy' => true,
359  'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
360  . ' indefinite (anonymous users only)',
361  'api' => [
362  'duration' => 'infinite',
363  'flags' => [ 'anononly' ],
364  ],
365  ],
366  ],
367  ];
368  }
369 
373  public function testSuppressReblockLogDatabaseRows( $row, $extra ) {
374  $this->doTestLogFormatter( $row, $extra );
375  }
376 }
testReblockLogDatabaseRows($row, $extra)
provideReblockLogDatabaseRows
testSuppressReblockLogDatabaseRows($row, $extra)
provideSuppressReblockLogDatabaseRows
testSuppressBlockLogDatabaseRows($row, $extra)
provideSuppressBlockLogDatabaseRows
static provideUnblockLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
testUnblockLogDatabaseRows($row, $extra)
provideUnblockLogDatabaseRows
static provideBlockLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
static provideReblockLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
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)
static provideSuppressBlockLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...
testBlockLogDatabaseRows($row, $extra)
provideBlockLogDatabaseRows
static provideSuppressReblockLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility. ...