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