Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / logging / MoveLogFormatterTest.php
blob719d0aa68825482de01b08c26bd4b4eadf1ad1f2
1 <?php
3 /**
4 * @covers \MoveLogFormatter
5 */
6 class MoveLogFormatterTest extends LogFormatterTestCase {
8 /**
9 * Provide different rows from the logging table to test
10 * for backward compatibility.
11 * Do not change the existing data, just add a new database row
13 public static function provideMoveLogDatabaseRows() {
14 return [
15 // Current format - with redirect
18 'type' => 'move',
19 'action' => 'move',
20 'comment' => 'move comment with redirect',
21 'namespace' => NS_MAIN,
22 'title' => 'OldPage',
23 'params' => [
24 '4::target' => 'NewPage',
25 '5::noredir' => '0',
29 'text' => 'User moved page OldPage to NewPage',
30 'api' => [
31 'target_ns' => 0,
32 'target_title' => 'NewPage',
33 'suppressredirect' => false,
38 // Current format - without redirect
41 'type' => 'move',
42 'action' => 'move',
43 'comment' => 'move comment',
44 'namespace' => NS_MAIN,
45 'title' => 'OldPage',
46 'params' => [
47 '4::target' => 'NewPage',
48 '5::noredir' => '1',
52 'text' => 'User moved page OldPage to NewPage without leaving a redirect',
53 'api' => [
54 'target_ns' => 0,
55 'target_title' => 'NewPage',
56 'suppressredirect' => true,
61 // legacy format - with redirect
64 'type' => 'move',
65 'action' => 'move',
66 'comment' => 'move comment',
67 'namespace' => NS_MAIN,
68 'title' => 'OldPage',
69 'params' => [
70 'NewPage',
71 '',
75 'legacy' => true,
76 'text' => 'User moved page OldPage to NewPage',
77 'api' => [
78 'target_ns' => 0,
79 'target_title' => 'NewPage',
80 'suppressredirect' => false,
85 // legacy format - without redirect
88 'type' => 'move',
89 'action' => 'move',
90 'comment' => 'move comment',
91 'namespace' => NS_MAIN,
92 'title' => 'OldPage',
93 'params' => [
94 'NewPage',
95 '1',
99 'legacy' => true,
100 'text' => 'User moved page OldPage to NewPage without leaving a redirect',
101 'api' => [
102 'target_ns' => 0,
103 'target_title' => 'NewPage',
104 'suppressredirect' => true,
109 // old format without flag for redirect suppression
112 'type' => 'move',
113 'action' => 'move',
114 'comment' => 'move comment',
115 'namespace' => NS_MAIN,
116 'title' => 'OldPage',
117 'params' => [
118 'NewPage',
122 'legacy' => true,
123 'text' => 'User moved page OldPage to NewPage',
124 'api' => [
125 'target_ns' => 0,
126 'target_title' => 'NewPage',
127 'suppressredirect' => false,
132 // row with invalid title (T370396)
135 'type' => 'move',
136 'action' => 'move',
137 'comment' => 'comment',
138 'namespace' => NS_TALK,
139 'title' => 'OldPage',
140 'params' => [
141 '4::target' => 'Talk:Help:NewPage',
142 '5::noredir' => '0',
146 'text' => 'User moved page Talk:OldPage to Invalid title',
147 'api' => [
148 'target_ns' => -1,
149 'target_title' => 'Special:Badtitle/Talk:Help:NewPage',
150 'suppressredirect' => false,
152 'preload' => [ /* empty, do not try to preload the bad title */ ],
159 * @dataProvider provideMoveLogDatabaseRows
161 public function testMoveLogDatabaseRows( $row, $extra ) {
162 $this->doTestLogFormatter( $row, $extra );
166 * Provide different rows from the logging table to test
167 * for backward compatibility.
168 * Do not change the existing data, just add a new database row
170 public static function provideMoveRedirLogDatabaseRows() {
171 return [
172 // Current format - with redirect
175 'type' => 'move',
176 'action' => 'move_redir',
177 'comment' => 'move comment with redirect',
178 'namespace' => NS_MAIN,
179 'title' => 'OldPage',
180 'params' => [
181 '4::target' => 'NewPage',
182 '5::noredir' => '0',
186 'text' => 'User moved page OldPage to NewPage over redirect',
187 'api' => [
188 'target_ns' => 0,
189 'target_title' => 'NewPage',
190 'suppressredirect' => false,
195 // Current format - without redirect
198 'type' => 'move',
199 'action' => 'move_redir',
200 'comment' => 'move comment',
201 'namespace' => NS_MAIN,
202 'title' => 'OldPage',
203 'params' => [
204 '4::target' => 'NewPage',
205 '5::noredir' => '1',
209 'text' => 'User moved page OldPage to NewPage over a redirect without leaving a redirect',
210 'api' => [
211 'target_ns' => 0,
212 'target_title' => 'NewPage',
213 'suppressredirect' => true,
218 // legacy format - with redirect
221 'type' => 'move',
222 'action' => 'move_redir',
223 'comment' => 'move comment',
224 'namespace' => NS_MAIN,
225 'title' => 'OldPage',
226 'params' => [
227 'NewPage',
232 'legacy' => true,
233 'text' => 'User moved page OldPage to NewPage over redirect',
234 'api' => [
235 'target_ns' => 0,
236 'target_title' => 'NewPage',
237 'suppressredirect' => false,
242 // legacy format - without redirect
245 'type' => 'move',
246 'action' => 'move_redir',
247 'comment' => 'move comment',
248 'namespace' => NS_MAIN,
249 'title' => 'OldPage',
250 'params' => [
251 'NewPage',
252 '1',
256 'legacy' => true,
257 'text' => 'User moved page OldPage to NewPage over a redirect without leaving a redirect',
258 'api' => [
259 'target_ns' => 0,
260 'target_title' => 'NewPage',
261 'suppressredirect' => true,
266 // old format without flag for redirect suppression
269 'type' => 'move',
270 'action' => 'move_redir',
271 'comment' => 'move comment',
272 'namespace' => NS_MAIN,
273 'title' => 'OldPage',
274 'params' => [
275 'NewPage',
279 'legacy' => true,
280 'text' => 'User moved page OldPage to NewPage over redirect',
281 'api' => [
282 'target_ns' => 0,
283 'target_title' => 'NewPage',
284 'suppressredirect' => false,
292 * @dataProvider provideMoveRedirLogDatabaseRows
294 public function testMoveRedirLogDatabaseRows( $row, $extra ) {
295 $this->doTestLogFormatter( $row, $extra );