Merge "Add grep comment for js vars wgRestriction*"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiComparePagesTest.php
1 <?php
2
3 /**
4 * @group API
5 * @group Database
6 * @group medium
7 * @covers ApiComparePages
8 */
9 class ApiComparePagesTest extends ApiTestCase {
10
11 protected static $repl = [];
12
13 protected function setUp() {
14 parent::setUp();
15
16 // Set $wgExternalDiffEngine to something bogus to try to force use of
17 // the PHP engine rather than wikidiff2.
18 $this->setMwGlobals( [
19 'wgExternalDiffEngine' => '/dev/null',
20 ] );
21 }
22
23 protected function addPage( $page, $text, $model = CONTENT_MODEL_WIKITEXT ) {
24 $title = Title::newFromText( 'ApiComparePagesTest ' . $page );
25 $content = ContentHandler::makeContent( $text, $title, $model );
26
27 $page = WikiPage::factory( $title );
28 $user = static::getTestSysop()->getUser();
29 $status = $page->doEditContent(
30 $content, 'Test for ApiComparePagesTest: ' . $text, 0, false, $user
31 );
32 if ( !$status->isOK() ) {
33 $this->fail( "Failed to create $title: " . $status->getWikiText( false, false, 'en' ) );
34 }
35 return $status->value['revision']->getId();
36 }
37
38 public function addDBDataOnce() {
39 $user = static::getTestSysop()->getUser();
40 self::$repl['creator'] = $user->getName();
41 self::$repl['creatorid'] = $user->getId();
42
43 self::$repl['revA1'] = $this->addPage( 'A', 'A 1' );
44 self::$repl['revA2'] = $this->addPage( 'A', 'A 2' );
45 self::$repl['revA3'] = $this->addPage( 'A', 'A 3' );
46 self::$repl['revA4'] = $this->addPage( 'A', 'A 4' );
47 self::$repl['pageA'] = Title::newFromText( 'ApiComparePagesTest A' )->getArticleId();
48
49 self::$repl['revB1'] = $this->addPage( 'B', 'B 1' );
50 self::$repl['revB2'] = $this->addPage( 'B', 'B 2' );
51 self::$repl['revB3'] = $this->addPage( 'B', 'B 3' );
52 self::$repl['revB4'] = $this->addPage( 'B', 'B 4' );
53 self::$repl['pageB'] = Title::newFromText( 'ApiComparePagesTest B' )->getArticleId();
54
55 self::$repl['revC1'] = $this->addPage( 'C', 'C 1' );
56 self::$repl['revC2'] = $this->addPage( 'C', 'C 2' );
57 self::$repl['revC3'] = $this->addPage( 'C', 'C 3' );
58 self::$repl['pageC'] = Title::newFromText( 'ApiComparePagesTest C' )->getArticleId();
59
60 $id = $this->addPage( 'D', 'D 1' );
61 self::$repl['pageD'] = Title::newFromText( 'ApiComparePagesTest D' )->getArticleId();
62 wfGetDB( DB_MASTER )->delete( 'revision', [ 'rev_id' => $id ] );
63
64 self::$repl['revE1'] = $this->addPage( 'E', 'E 1' );
65 self::$repl['revE2'] = $this->addPage( 'E', 'E 2' );
66 self::$repl['revE3'] = $this->addPage( 'E', 'E 3' );
67 self::$repl['revE4'] = $this->addPage( 'E', 'E 4' );
68 self::$repl['pageE'] = Title::newFromText( 'ApiComparePagesTest E' )->getArticleId();
69 wfGetDB( DB_MASTER )->update(
70 'page', [ 'page_latest' => 0 ], [ 'page_id' => self::$repl['pageE'] ]
71 );
72
73 WikiPage::factory( Title::newFromText( 'ApiComparePagesTest C' ) )
74 ->doDeleteArticleReal( 'Test for ApiComparePagesTest' );
75
76 RevisionDeleter::createList(
77 'revision',
78 RequestContext::getMain(),
79 Title::newFromText( 'ApiComparePagesTest B' ),
80 [ self::$repl['revB2'] ]
81 )->setVisibility( [
82 'value' => [
83 Revision::DELETED_TEXT => 1,
84 Revision::DELETED_USER => 1,
85 Revision::DELETED_COMMENT => 1,
86 ],
87 'comment' => 'Test for ApiComparePages',
88 ] );
89
90 RevisionDeleter::createList(
91 'revision',
92 RequestContext::getMain(),
93 Title::newFromText( 'ApiComparePagesTest B' ),
94 [ self::$repl['revB3'] ]
95 )->setVisibility( [
96 'value' => [
97 Revision::DELETED_USER => 1,
98 Revision::DELETED_COMMENT => 1,
99 Revision::DELETED_RESTRICTED => 1,
100 ],
101 'comment' => 'Test for ApiComparePages',
102 ] );
103
104 Title::clearCaches(); // Otherwise it has the wrong latest revision for some reason
105 }
106
107 protected function doReplacements( &$value ) {
108 if ( is_string( $value ) ) {
109 if ( preg_match( '/^{{REPL:(.+?)}}$/', $value, $m ) ) {
110 $value = self::$repl[$m[1]];
111 } else {
112 $value = preg_replace_callback( '/{{REPL:(.+?)}}/', function ( $m ) {
113 return isset( self::$repl[$m[1]] ) ? self::$repl[$m[1]] : $m[0];
114 }, $value );
115 }
116 } elseif ( is_array( $value ) || is_object( $value ) ) {
117 foreach ( $value as &$v ) {
118 $this->doReplacements( $v );
119 }
120 unset( $v );
121 }
122 }
123
124 /**
125 * @dataProvider provideDiff
126 */
127 public function testDiff( $params, $expect, $exceptionCode = false, $sysop = false ) {
128 $this->doReplacements( $params );
129
130 $params += [
131 'action' => 'compare',
132 ];
133
134 $user = $sysop
135 ? static::getTestSysop()->getUser()
136 : static::getTestUser()->getUser();
137 if ( $exceptionCode ) {
138 try {
139 $this->doApiRequest( $params, null, false, $user );
140 $this->fail( 'Expected exception not thrown' );
141 } catch ( ApiUsageException $ex ) {
142 $this->assertTrue( $this->apiExceptionHasCode( $ex, $exceptionCode ),
143 "Exception with code $exceptionCode" );
144 }
145 } else {
146 $apiResult = $this->doApiRequest( $params, null, false, $user );
147 $apiResult = $apiResult[0];
148 $this->doReplacements( $expect );
149 $this->assertEquals( $expect, $apiResult );
150 }
151 }
152
153 public static function provideDiff() {
154 return [
155 // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong
156 'Basic diff, titles' => [
157 [
158 'fromtitle' => 'ApiComparePagesTest A',
159 'totitle' => 'ApiComparePagesTest B',
160 ],
161 [
162 'compare' => [
163 'fromid' => '{{REPL:pageA}}',
164 'fromrevid' => '{{REPL:revA4}}',
165 'fromns' => 0,
166 'fromtitle' => 'ApiComparePagesTest A',
167 'toid' => '{{REPL:pageB}}',
168 'torevid' => '{{REPL:revB4}}',
169 'tons' => 0,
170 'totitle' => 'ApiComparePagesTest B',
171 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
172 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
173 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">A </del>4</div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">B </ins>4</div></td></tr>' . "\n",
174 ]
175 ],
176 ],
177 'Basic diff, page IDs' => [
178 [
179 'fromid' => '{{REPL:pageA}}',
180 'toid' => '{{REPL:pageB}}',
181 ],
182 [
183 'compare' => [
184 'fromid' => '{{REPL:pageA}}',
185 'fromrevid' => '{{REPL:revA4}}',
186 'fromns' => 0,
187 'fromtitle' => 'ApiComparePagesTest A',
188 'toid' => '{{REPL:pageB}}',
189 'torevid' => '{{REPL:revB4}}',
190 'tons' => 0,
191 'totitle' => 'ApiComparePagesTest B',
192 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
193 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
194 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">A </del>4</div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">B </ins>4</div></td></tr>' . "\n",
195 ]
196 ],
197 ],
198 'Basic diff, revision IDs' => [
199 [
200 'fromrev' => '{{REPL:revA2}}',
201 'torev' => '{{REPL:revA3}}',
202 ],
203 [
204 'compare' => [
205 'fromid' => '{{REPL:pageA}}',
206 'fromrevid' => '{{REPL:revA2}}',
207 'fromns' => 0,
208 'fromtitle' => 'ApiComparePagesTest A',
209 'toid' => '{{REPL:pageA}}',
210 'torevid' => '{{REPL:revA3}}',
211 'tons' => 0,
212 'totitle' => 'ApiComparePagesTest A',
213 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
214 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
215 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div>A <del class="diffchange diffchange-inline">2</del></div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div>A <ins class="diffchange diffchange-inline">3</ins></div></td></tr>' . "\n",
216 ]
217 ],
218 ],
219 'Basic diff, deleted revision ID as sysop' => [
220 [
221 'fromrev' => '{{REPL:revA2}}',
222 'torev' => '{{REPL:revC2}}',
223 ],
224 [
225 'compare' => [
226 'fromid' => '{{REPL:pageA}}',
227 'fromrevid' => '{{REPL:revA2}}',
228 'fromns' => 0,
229 'fromtitle' => 'ApiComparePagesTest A',
230 'toid' => 0,
231 'torevid' => '{{REPL:revC2}}',
232 'tons' => 0,
233 'totitle' => 'ApiComparePagesTest C',
234 'toarchive' => true,
235 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
236 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
237 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">A </del>2</div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">C </ins>2</div></td></tr>' . "\n",
238 ]
239 ],
240 false, true
241 ],
242 'Basic diff, revdel as sysop' => [
243 [
244 'fromrev' => '{{REPL:revA2}}',
245 'torev' => '{{REPL:revB2}}',
246 ],
247 [
248 'compare' => [
249 'fromid' => '{{REPL:pageA}}',
250 'fromrevid' => '{{REPL:revA2}}',
251 'fromns' => 0,
252 'fromtitle' => 'ApiComparePagesTest A',
253 'toid' => '{{REPL:pageB}}',
254 'torevid' => '{{REPL:revB2}}',
255 'tons' => 0,
256 'totitle' => 'ApiComparePagesTest B',
257 'totexthidden' => true,
258 'touserhidden' => true,
259 'tocommenthidden' => true,
260 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
261 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
262 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">A </del>2</div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">B </ins>2</div></td></tr>' . "\n",
263 ]
264 ],
265 false, true
266 ],
267 'Basic diff, text' => [
268 [
269 'fromtext' => 'From text',
270 'fromcontentmodel' => 'wikitext',
271 'totext' => 'To text {{subst:PAGENAME}}',
272 'tocontentmodel' => 'wikitext',
273 ],
274 [
275 'compare' => [
276 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
277 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
278 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">From </del>text</div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">To </ins>text <ins class="diffchange diffchange-inline">{{subst:PAGENAME}}</ins></div></td></tr>' . "\n",
279 ]
280 ],
281 ],
282 'Basic diff, text 2' => [
283 [
284 'fromtext' => 'From text',
285 'totext' => 'To text {{subst:PAGENAME}}',
286 'tocontentmodel' => 'wikitext',
287 ],
288 [
289 'compare' => [
290 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
291 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
292 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">From </del>text</div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">To </ins>text <ins class="diffchange diffchange-inline">{{subst:PAGENAME}}</ins></div></td></tr>' . "\n",
293 ]
294 ],
295 ],
296 'Basic diff, guessed model' => [
297 [
298 'fromtext' => 'From text',
299 'totext' => 'To text',
300 ],
301 [
302 'warnings' => [
303 'compare' => [
304 'warnings' => 'No content model could be determined, assuming wikitext.',
305 ],
306 ],
307 'compare' => [
308 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
309 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
310 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">From </del>text</div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">To </ins>text</div></td></tr>' . "\n",
311 ]
312 ],
313 ],
314 'Basic diff, text with title and PST' => [
315 [
316 'fromtext' => 'From text',
317 'totitle' => 'Test',
318 'totext' => 'To text {{subst:PAGENAME}}',
319 'topst' => true,
320 ],
321 [
322 'compare' => [
323 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
324 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
325 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">From </del>text</div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">To </ins>text <ins class="diffchange diffchange-inline">Test</ins></div></td></tr>' . "\n",
326 ]
327 ],
328 ],
329 'Basic diff, text with page ID and PST' => [
330 [
331 'fromtext' => 'From text',
332 'toid' => '{{REPL:pageB}}',
333 'totext' => 'To text {{subst:PAGENAME}}',
334 'topst' => true,
335 ],
336 [
337 'compare' => [
338 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
339 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
340 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">From </del>text</div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">To </ins>text <ins class="diffchange diffchange-inline">ApiComparePagesTest B</ins></div></td></tr>' . "\n",
341 ]
342 ],
343 ],
344 'Basic diff, text with revision and PST' => [
345 [
346 'fromtext' => 'From text',
347 'torev' => '{{REPL:revB2}}',
348 'totext' => 'To text {{subst:PAGENAME}}',
349 'topst' => true,
350 ],
351 [
352 'compare' => [
353 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
354 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
355 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">From </del>text</div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">To </ins>text <ins class="diffchange diffchange-inline">ApiComparePagesTest B</ins></div></td></tr>' . "\n",
356 ]
357 ],
358 ],
359 'Basic diff, text with deleted revision and PST' => [
360 [
361 'fromtext' => 'From text',
362 'torev' => '{{REPL:revC2}}',
363 'totext' => 'To text {{subst:PAGENAME}}',
364 'topst' => true,
365 ],
366 [
367 'compare' => [
368 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
369 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
370 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">From </del>text</div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">To </ins>text <ins class="diffchange diffchange-inline">ApiComparePagesTest C</ins></div></td></tr>' . "\n",
371 ]
372 ],
373 false, true
374 ],
375 'Diff with all props' => [
376 [
377 'fromrev' => '{{REPL:revB1}}',
378 'torev' => '{{REPL:revB3}}',
379 'totitle' => 'ApiComparePagesTest B',
380 'prop' => 'diff|diffsize|rel|ids|title|user|comment|parsedcomment|size'
381 ],
382 [
383 'compare' => [
384 'fromid' => '{{REPL:pageB}}',
385 'fromrevid' => '{{REPL:revB1}}',
386 'fromns' => 0,
387 'fromtitle' => 'ApiComparePagesTest B',
388 'fromsize' => 3,
389 'fromuser' => '{{REPL:creator}}',
390 'fromuserid' => '{{REPL:creatorid}}',
391 'fromcomment' => 'Test for ApiComparePagesTest: B 1',
392 'fromparsedcomment' => 'Test for ApiComparePagesTest: B 1',
393 'toid' => '{{REPL:pageB}}',
394 'torevid' => '{{REPL:revB3}}',
395 'tons' => 0,
396 'totitle' => 'ApiComparePagesTest B',
397 'tosize' => 3,
398 'touserhidden' => true,
399 'tocommenthidden' => true,
400 'tosuppressed' => true,
401 'next' => '{{REPL:revB4}}',
402 'diffsize' => 391,
403 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
404 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
405 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div>B <del class="diffchange diffchange-inline">1</del></div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div>B <ins class="diffchange diffchange-inline">3</ins></div></td></tr>' . "\n",
406 ]
407 ],
408 ],
409 'Diff with all props as sysop' => [
410 [
411 'fromrev' => '{{REPL:revB2}}',
412 'torev' => '{{REPL:revB3}}',
413 'totitle' => 'ApiComparePagesTest B',
414 'prop' => 'diff|diffsize|rel|ids|title|user|comment|parsedcomment|size'
415 ],
416 [
417 'compare' => [
418 'fromid' => '{{REPL:pageB}}',
419 'fromrevid' => '{{REPL:revB2}}',
420 'fromns' => 0,
421 'fromtitle' => 'ApiComparePagesTest B',
422 'fromsize' => 3,
423 'fromtexthidden' => true,
424 'fromuserhidden' => true,
425 'fromuser' => '{{REPL:creator}}',
426 'fromuserid' => '{{REPL:creatorid}}',
427 'fromcommenthidden' => true,
428 'fromcomment' => 'Test for ApiComparePagesTest: B 2',
429 'fromparsedcomment' => 'Test for ApiComparePagesTest: B 2',
430 'toid' => '{{REPL:pageB}}',
431 'torevid' => '{{REPL:revB3}}',
432 'tons' => 0,
433 'totitle' => 'ApiComparePagesTest B',
434 'tosize' => 3,
435 'touserhidden' => true,
436 'tocommenthidden' => true,
437 'tosuppressed' => true,
438 'prev' => '{{REPL:revB1}}',
439 'next' => '{{REPL:revB4}}',
440 'diffsize' => 391,
441 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
442 . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
443 . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div>B <del class="diffchange diffchange-inline">2</del></div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div>B <ins class="diffchange diffchange-inline">3</ins></div></td></tr>' . "\n",
444 ]
445 ],
446 false, true
447 ],
448 'Relative diff, cur' => [
449 [
450 'fromrev' => '{{REPL:revA2}}',
451 'torelative' => 'cur',
452 'prop' => 'ids',
453 ],
454 [
455 'compare' => [
456 'fromid' => '{{REPL:pageA}}',
457 'fromrevid' => '{{REPL:revA2}}',
458 'toid' => '{{REPL:pageA}}',
459 'torevid' => '{{REPL:revA4}}',
460 ]
461 ],
462 ],
463 'Relative diff, next' => [
464 [
465 'fromrev' => '{{REPL:revE2}}',
466 'torelative' => 'next',
467 'prop' => 'ids|rel',
468 ],
469 [
470 'compare' => [
471 'fromid' => '{{REPL:pageE}}',
472 'fromrevid' => '{{REPL:revE2}}',
473 'toid' => '{{REPL:pageE}}',
474 'torevid' => '{{REPL:revE3}}',
475 'prev' => '{{REPL:revE1}}',
476 'next' => '{{REPL:revE4}}',
477 ]
478 ],
479 ],
480 'Relative diff, prev' => [
481 [
482 'fromrev' => '{{REPL:revE3}}',
483 'torelative' => 'prev',
484 'prop' => 'ids|rel',
485 ],
486 [
487 'compare' => [
488 'fromid' => '{{REPL:pageE}}',
489 'fromrevid' => '{{REPL:revE2}}',
490 'toid' => '{{REPL:pageE}}',
491 'torevid' => '{{REPL:revE3}}',
492 'prev' => '{{REPL:revE1}}',
493 'next' => '{{REPL:revE4}}',
494 ]
495 ],
496 ],
497
498 'Error, missing title' => [
499 [
500 'fromtitle' => 'ApiComparePagesTest X',
501 'totitle' => 'ApiComparePagesTest B',
502 ],
503 [],
504 'missingtitle',
505 ],
506 'Error, invalid title' => [
507 [
508 'fromtitle' => '<bad>',
509 'totitle' => 'ApiComparePagesTest B',
510 ],
511 [],
512 'invalidtitle',
513 ],
514 'Error, missing page ID' => [
515 [
516 'fromid' => 8817900,
517 'totitle' => 'ApiComparePagesTest B',
518 ],
519 [],
520 'nosuchpageid',
521 ],
522 'Error, page with missing revision' => [
523 [
524 'fromtitle' => 'ApiComparePagesTest D',
525 'totitle' => 'ApiComparePagesTest B',
526 ],
527 [],
528 'nosuchrevid',
529 ],
530 'Error, page with no revision' => [
531 [
532 'fromtitle' => 'ApiComparePagesTest E',
533 'totitle' => 'ApiComparePagesTest B',
534 ],
535 [],
536 'nosuchrevid',
537 ],
538 'Error, bad rev ID' => [
539 [
540 'fromrev' => 8817900,
541 'totitle' => 'ApiComparePagesTest B',
542 ],
543 [],
544 'nosuchrevid',
545 ],
546 'Error, deleted revision ID, non-sysop' => [
547 [
548 'fromrev' => '{{REPL:revA2}}',
549 'torev' => '{{REPL:revC2}}',
550 ],
551 [],
552 'nosuchrevid',
553 ],
554 'Error, revision-deleted content' => [
555 [
556 'fromrev' => '{{REPL:revA2}}',
557 'torev' => '{{REPL:revB2}}',
558 ],
559 [],
560 'missingcontent',
561 ],
562 'Error, text with no title and PST' => [
563 [
564 'fromtext' => 'From text',
565 'totext' => 'To text {{subst:PAGENAME}}',
566 'topst' => true,
567 ],
568 [],
569 'compare-no-title',
570 ],
571 'Error, Relative diff, no from revision' => [
572 [
573 'fromtext' => 'Foo',
574 'torelative' => 'cur',
575 'prop' => 'ids',
576 ],
577 [],
578 'compare-relative-to-nothing'
579 ],
580 'Error, Relative diff, cur with no current revision' => [
581 [
582 'fromrev' => '{{REPL:revE2}}',
583 'torelative' => 'cur',
584 'prop' => 'ids',
585 ],
586 [],
587 'nosuchrevid'
588 ],
589 'Error, Relative diff, next revdeleted' => [
590 [
591 'fromrev' => '{{REPL:revB1}}',
592 'torelative' => 'next',
593 'prop' => 'ids',
594 ],
595 [],
596 'missingcontent'
597 ],
598 'Error, Relative diff, prev revdeleted' => [
599 [
600 'fromrev' => '{{REPL:revB3}}',
601 'torelative' => 'prev',
602 'prop' => 'ids',
603 ],
604 [],
605 'missingcontent'
606 ],
607
608 // @codingStandardsIgnoreEnd
609 ];
610 }
611 }