MediaWiki  1.29.1
MoveLogFormatterTest.php
Go to the documentation of this file.
1 <?php
2 
4 
10  public static function provideMoveLogDatabaseRows() {
11  return [
12  // Current format - with redirect
13  [
14  [
15  'type' => 'move',
16  'action' => 'move',
17  'comment' => 'move comment with redirect',
18  'namespace' => NS_MAIN,
19  'title' => 'OldPage',
20  'params' => [
21  '4::target' => 'NewPage',
22  '5::noredir' => '0',
23  ],
24  ],
25  [
26  'text' => 'User moved page OldPage to NewPage',
27  'api' => [
28  'target_ns' => 0,
29  'target_title' => 'NewPage',
30  'suppressredirect' => false,
31  ],
32  ],
33  ],
34 
35  // Current format - without redirect
36  [
37  [
38  'type' => 'move',
39  'action' => 'move',
40  'comment' => 'move comment',
41  'namespace' => NS_MAIN,
42  'title' => 'OldPage',
43  'params' => [
44  '4::target' => 'NewPage',
45  '5::noredir' => '1',
46  ],
47  ],
48  [
49  'text' => 'User moved page OldPage to NewPage without leaving a redirect',
50  'api' => [
51  'target_ns' => 0,
52  'target_title' => 'NewPage',
53  'suppressredirect' => true,
54  ],
55  ],
56  ],
57 
58  // legacy format - with redirect
59  [
60  [
61  'type' => 'move',
62  'action' => 'move',
63  'comment' => 'move comment',
64  'namespace' => NS_MAIN,
65  'title' => 'OldPage',
66  'params' => [
67  'NewPage',
68  '',
69  ],
70  ],
71  [
72  'legacy' => true,
73  'text' => 'User moved page OldPage to NewPage',
74  'api' => [
75  'target_ns' => 0,
76  'target_title' => 'NewPage',
77  'suppressredirect' => false,
78  ],
79  ],
80  ],
81 
82  // legacy format - without redirect
83  [
84  [
85  'type' => 'move',
86  'action' => 'move',
87  'comment' => 'move comment',
88  'namespace' => NS_MAIN,
89  'title' => 'OldPage',
90  'params' => [
91  'NewPage',
92  '1',
93  ],
94  ],
95  [
96  'legacy' => true,
97  'text' => 'User moved page OldPage to NewPage without leaving a redirect',
98  'api' => [
99  'target_ns' => 0,
100  'target_title' => 'NewPage',
101  'suppressredirect' => true,
102  ],
103  ],
104  ],
105 
106  // old format without flag for redirect suppression
107  [
108  [
109  'type' => 'move',
110  'action' => 'move',
111  'comment' => 'move comment',
112  'namespace' => NS_MAIN,
113  'title' => 'OldPage',
114  'params' => [
115  'NewPage',
116  ],
117  ],
118  [
119  'legacy' => true,
120  'text' => 'User moved page OldPage to NewPage',
121  'api' => [
122  'target_ns' => 0,
123  'target_title' => 'NewPage',
124  'suppressredirect' => false,
125  ],
126  ],
127  ],
128  ];
129  }
130 
134  public function testMoveLogDatabaseRows( $row, $extra ) {
135  $this->doTestLogFormatter( $row, $extra );
136  }
137 
143  public static function provideMoveRedirLogDatabaseRows() {
144  return [
145  // Current format - with redirect
146  [
147  [
148  'type' => 'move',
149  'action' => 'move_redir',
150  'comment' => 'move comment with redirect',
151  'namespace' => NS_MAIN,
152  'title' => 'OldPage',
153  'params' => [
154  '4::target' => 'NewPage',
155  '5::noredir' => '0',
156  ],
157  ],
158  [
159  'text' => 'User moved page OldPage to NewPage over redirect',
160  'api' => [
161  'target_ns' => 0,
162  'target_title' => 'NewPage',
163  'suppressredirect' => false,
164  ],
165  ],
166  ],
167 
168  // Current format - without redirect
169  [
170  [
171  'type' => 'move',
172  'action' => 'move_redir',
173  'comment' => 'move comment',
174  'namespace' => NS_MAIN,
175  'title' => 'OldPage',
176  'params' => [
177  '4::target' => 'NewPage',
178  '5::noredir' => '1',
179  ],
180  ],
181  [
182  'text' => 'User moved page OldPage to NewPage over a redirect without leaving a redirect',
183  'api' => [
184  'target_ns' => 0,
185  'target_title' => 'NewPage',
186  'suppressredirect' => true,
187  ],
188  ],
189  ],
190 
191  // legacy format - with redirect
192  [
193  [
194  'type' => 'move',
195  'action' => 'move_redir',
196  'comment' => 'move comment',
197  'namespace' => NS_MAIN,
198  'title' => 'OldPage',
199  'params' => [
200  'NewPage',
201  '',
202  ],
203  ],
204  [
205  'legacy' => true,
206  'text' => 'User moved page OldPage to NewPage over redirect',
207  'api' => [
208  'target_ns' => 0,
209  'target_title' => 'NewPage',
210  'suppressredirect' => false,
211  ],
212  ],
213  ],
214 
215  // legacy format - without redirect
216  [
217  [
218  'type' => 'move',
219  'action' => 'move_redir',
220  'comment' => 'move comment',
221  'namespace' => NS_MAIN,
222  'title' => 'OldPage',
223  'params' => [
224  'NewPage',
225  '1',
226  ],
227  ],
228  [
229  'legacy' => true,
230  'text' => 'User moved page OldPage to NewPage over a redirect without leaving a redirect',
231  'api' => [
232  'target_ns' => 0,
233  'target_title' => 'NewPage',
234  'suppressredirect' => true,
235  ],
236  ],
237  ],
238 
239  // old format without flag for redirect suppression
240  [
241  [
242  'type' => 'move',
243  'action' => 'move_redir',
244  'comment' => 'move comment',
245  'namespace' => NS_MAIN,
246  'title' => 'OldPage',
247  'params' => [
248  'NewPage',
249  ],
250  ],
251  [
252  'legacy' => true,
253  'text' => 'User moved page OldPage to NewPage over redirect',
254  'api' => [
255  'target_ns' => 0,
256  'target_title' => 'NewPage',
257  'suppressredirect' => false,
258  ],
259  ],
260  ],
261  ];
262  }
263 
267  public function testMoveRedirLogDatabaseRows( $row, $extra ) {
268  $this->doTestLogFormatter( $row, $extra );
269  }
270 }
php
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
NS_MAIN
const NS_MAIN
Definition: Defines.php:62
LogFormatterTestCase
Definition: LogFormatterTestCase.php:6
MoveLogFormatterTest\provideMoveLogDatabaseRows
static provideMoveLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
Definition: MoveLogFormatterTest.php:10
MoveLogFormatterTest\testMoveLogDatabaseRows
testMoveLogDatabaseRows( $row, $extra)
provideMoveLogDatabaseRows
Definition: MoveLogFormatterTest.php:134
MoveLogFormatterTest\provideMoveRedirLogDatabaseRows
static provideMoveRedirLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
Definition: MoveLogFormatterTest.php:143
MoveLogFormatterTest
Definition: MoveLogFormatterTest.php:3
LogFormatterTestCase\doTestLogFormatter
doTestLogFormatter( $row, $extra)
Definition: LogFormatterTestCase.php:8
MoveLogFormatterTest\testMoveRedirLogDatabaseRows
testMoveRedirLogDatabaseRows( $row, $extra)
provideMoveRedirLogDatabaseRows
Definition: MoveLogFormatterTest.php:267