ApiComparePagesTest.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. <?php
  2. /**
  3. * @group API
  4. * @group Database
  5. * @group medium
  6. * @covers ApiComparePages
  7. */
  8. class ApiComparePagesTest extends ApiTestCase {
  9. protected static $repl = [];
  10. protected function setUp() {
  11. parent::setUp();
  12. // Set $wgExternalDiffEngine to something bogus to try to force use of
  13. // the PHP engine rather than wikidiff2.
  14. $this->setMwGlobals( [
  15. 'wgExternalDiffEngine' => '/dev/null',
  16. ] );
  17. }
  18. protected function addPage( $page, $text, $model = CONTENT_MODEL_WIKITEXT ) {
  19. $title = Title::newFromText( 'ApiComparePagesTest ' . $page );
  20. $content = ContentHandler::makeContent( $text, $title, $model );
  21. $page = WikiPage::factory( $title );
  22. $user = static::getTestSysop()->getUser();
  23. $status = $page->doEditContent(
  24. $content, 'Test for ApiComparePagesTest: ' . $text, 0, false, $user
  25. );
  26. if ( !$status->isOK() ) {
  27. $this->fail( "Failed to create $title: " . $status->getWikiText( false, false, 'en' ) );
  28. }
  29. return $status->value['revision']->getId();
  30. }
  31. public function addDBDataOnce() {
  32. $user = static::getTestSysop()->getUser();
  33. self::$repl['creator'] = $user->getName();
  34. self::$repl['creatorid'] = $user->getId();
  35. self::$repl['revA1'] = $this->addPage( 'A', 'A 1' );
  36. self::$repl['revA2'] = $this->addPage( 'A', 'A 2' );
  37. self::$repl['revA3'] = $this->addPage( 'A', 'A 3' );
  38. self::$repl['revA4'] = $this->addPage( 'A', 'A 4' );
  39. self::$repl['pageA'] = Title::newFromText( 'ApiComparePagesTest A' )->getArticleId();
  40. self::$repl['revB1'] = $this->addPage( 'B', 'B 1' );
  41. self::$repl['revB2'] = $this->addPage( 'B', 'B 2' );
  42. self::$repl['revB3'] = $this->addPage( 'B', 'B 3' );
  43. self::$repl['revB4'] = $this->addPage( 'B', 'B 4' );
  44. self::$repl['pageB'] = Title::newFromText( 'ApiComparePagesTest B' )->getArticleId();
  45. self::$repl['revC1'] = $this->addPage( 'C', 'C 1' );
  46. self::$repl['revC2'] = $this->addPage( 'C', 'C 2' );
  47. self::$repl['revC3'] = $this->addPage( 'C', 'C 3' );
  48. self::$repl['pageC'] = Title::newFromText( 'ApiComparePagesTest C' )->getArticleId();
  49. $id = $this->addPage( 'D', 'D 1' );
  50. self::$repl['pageD'] = Title::newFromText( 'ApiComparePagesTest D' )->getArticleId();
  51. wfGetDB( DB_MASTER )->delete( 'revision', [ 'rev_id' => $id ] );
  52. self::$repl['revE1'] = $this->addPage( 'E', 'E 1' );
  53. self::$repl['revE2'] = $this->addPage( 'E', 'E 2' );
  54. self::$repl['revE3'] = $this->addPage( 'E', 'E 3' );
  55. self::$repl['revE4'] = $this->addPage( 'E', 'E 4' );
  56. self::$repl['pageE'] = Title::newFromText( 'ApiComparePagesTest E' )->getArticleId();
  57. wfGetDB( DB_MASTER )->update(
  58. 'page', [ 'page_latest' => 0 ], [ 'page_id' => self::$repl['pageE'] ]
  59. );
  60. self::$repl['revF1'] = $this->addPage( 'F', "== Section 1 ==\nF 1.1\n\n== Section 2 ==\nF 1.2" );
  61. self::$repl['pageF'] = Title::newFromText( 'ApiComparePagesTest F' )->getArticleId();
  62. self::$repl['revG1'] = $this->addPage( 'G', "== Section 1 ==\nG 1.1", CONTENT_MODEL_TEXT );
  63. self::$repl['pageG'] = Title::newFromText( 'ApiComparePagesTest G' )->getArticleId();
  64. WikiPage::factory( Title::newFromText( 'ApiComparePagesTest C' ) )
  65. ->doDeleteArticleReal( 'Test for ApiComparePagesTest' );
  66. RevisionDeleter::createList(
  67. 'revision',
  68. RequestContext::getMain(),
  69. Title::newFromText( 'ApiComparePagesTest B' ),
  70. [ self::$repl['revB2'] ]
  71. )->setVisibility( [
  72. 'value' => [
  73. Revision::DELETED_TEXT => 1,
  74. Revision::DELETED_USER => 1,
  75. Revision::DELETED_COMMENT => 1,
  76. ],
  77. 'comment' => 'Test for ApiComparePages',
  78. ] );
  79. RevisionDeleter::createList(
  80. 'revision',
  81. RequestContext::getMain(),
  82. Title::newFromText( 'ApiComparePagesTest B' ),
  83. [ self::$repl['revB3'] ]
  84. )->setVisibility( [
  85. 'value' => [
  86. Revision::DELETED_USER => 1,
  87. Revision::DELETED_COMMENT => 1,
  88. Revision::DELETED_RESTRICTED => 1,
  89. ],
  90. 'comment' => 'Test for ApiComparePages',
  91. ] );
  92. Title::clearCaches(); // Otherwise it has the wrong latest revision for some reason
  93. }
  94. protected function doReplacements( &$value ) {
  95. if ( is_string( $value ) ) {
  96. if ( preg_match( '/^{{REPL:(.+?)}}$/', $value, $m ) ) {
  97. $value = self::$repl[$m[1]];
  98. } else {
  99. $value = preg_replace_callback( '/{{REPL:(.+?)}}/', function ( $m ) {
  100. return self::$repl[$m[1]] ?? $m[0];
  101. }, $value );
  102. }
  103. } elseif ( is_array( $value ) || is_object( $value ) ) {
  104. foreach ( $value as &$v ) {
  105. $this->doReplacements( $v );
  106. }
  107. unset( $v );
  108. }
  109. }
  110. /**
  111. * @dataProvider provideDiff
  112. */
  113. public function testDiff( $params, $expect, $exceptionCode = false, $sysop = false ) {
  114. $this->doReplacements( $params );
  115. $params += [
  116. 'action' => 'compare',
  117. 'errorformat' => 'none',
  118. ];
  119. $user = $sysop
  120. ? static::getTestSysop()->getUser()
  121. : static::getTestUser()->getUser();
  122. if ( $exceptionCode ) {
  123. try {
  124. $this->doApiRequest( $params, null, false, $user );
  125. $this->fail( 'Expected exception not thrown' );
  126. } catch ( ApiUsageException $ex ) {
  127. $this->assertTrue( $this->apiExceptionHasCode( $ex, $exceptionCode ),
  128. "Exception with code $exceptionCode" );
  129. }
  130. } else {
  131. $apiResult = $this->doApiRequest( $params, null, false, $user );
  132. $apiResult = $apiResult[0];
  133. $this->doReplacements( $expect );
  134. $this->assertEquals( $expect, $apiResult );
  135. }
  136. }
  137. private static function makeDeprecationWarnings( ...$params ) {
  138. $warn = [];
  139. foreach ( $params as $p ) {
  140. $warn[] = [
  141. 'code' => 'deprecation',
  142. 'data' => [ 'feature' => "action=compare&{$p}" ],
  143. 'module' => 'compare',
  144. ];
  145. if ( count( $warn ) === 1 ) {
  146. $warn[] = [
  147. 'code' => 'deprecation-help',
  148. 'module' => 'main',
  149. ];
  150. }
  151. }
  152. return $warn;
  153. }
  154. public static function provideDiff() {
  155. // phpcs:disable Generic.Files.LineLength.TooLong
  156. return [
  157. 'Basic diff, titles' => [
  158. [
  159. 'fromtitle' => 'ApiComparePagesTest A',
  160. 'totitle' => 'ApiComparePagesTest B',
  161. ],
  162. [
  163. 'compare' => [
  164. 'fromid' => '{{REPL:pageA}}',
  165. 'fromrevid' => '{{REPL:revA4}}',
  166. 'fromns' => 0,
  167. 'fromtitle' => 'ApiComparePagesTest A',
  168. 'toid' => '{{REPL:pageB}}',
  169. 'torevid' => '{{REPL:revB4}}',
  170. 'tons' => 0,
  171. 'totitle' => 'ApiComparePagesTest B',
  172. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  173. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  174. . '<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",
  175. ]
  176. ],
  177. ],
  178. 'Basic diff, page IDs' => [
  179. [
  180. 'fromid' => '{{REPL:pageA}}',
  181. 'toid' => '{{REPL:pageB}}',
  182. ],
  183. [
  184. 'compare' => [
  185. 'fromid' => '{{REPL:pageA}}',
  186. 'fromrevid' => '{{REPL:revA4}}',
  187. 'fromns' => 0,
  188. 'fromtitle' => 'ApiComparePagesTest A',
  189. 'toid' => '{{REPL:pageB}}',
  190. 'torevid' => '{{REPL:revB4}}',
  191. 'tons' => 0,
  192. 'totitle' => 'ApiComparePagesTest B',
  193. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  194. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  195. . '<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",
  196. ]
  197. ],
  198. ],
  199. 'Basic diff, revision IDs' => [
  200. [
  201. 'fromrev' => '{{REPL:revA2}}',
  202. 'torev' => '{{REPL:revA3}}',
  203. ],
  204. [
  205. 'compare' => [
  206. 'fromid' => '{{REPL:pageA}}',
  207. 'fromrevid' => '{{REPL:revA2}}',
  208. 'fromns' => 0,
  209. 'fromtitle' => 'ApiComparePagesTest A',
  210. 'toid' => '{{REPL:pageA}}',
  211. 'torevid' => '{{REPL:revA3}}',
  212. 'tons' => 0,
  213. 'totitle' => 'ApiComparePagesTest A',
  214. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  215. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  216. . '<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",
  217. ]
  218. ],
  219. ],
  220. 'Basic diff, deleted revision ID as sysop' => [
  221. [
  222. 'fromrev' => '{{REPL:revA2}}',
  223. 'torev' => '{{REPL:revC2}}',
  224. ],
  225. [
  226. 'compare' => [
  227. 'fromid' => '{{REPL:pageA}}',
  228. 'fromrevid' => '{{REPL:revA2}}',
  229. 'fromns' => 0,
  230. 'fromtitle' => 'ApiComparePagesTest A',
  231. 'toid' => 0,
  232. 'torevid' => '{{REPL:revC2}}',
  233. 'tons' => 0,
  234. 'totitle' => 'ApiComparePagesTest C',
  235. 'toarchive' => true,
  236. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  237. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  238. . '<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",
  239. ]
  240. ],
  241. false, true
  242. ],
  243. 'Basic diff, revdel as sysop' => [
  244. [
  245. 'fromrev' => '{{REPL:revA2}}',
  246. 'torev' => '{{REPL:revB2}}',
  247. ],
  248. [
  249. 'compare' => [
  250. 'fromid' => '{{REPL:pageA}}',
  251. 'fromrevid' => '{{REPL:revA2}}',
  252. 'fromns' => 0,
  253. 'fromtitle' => 'ApiComparePagesTest A',
  254. 'toid' => '{{REPL:pageB}}',
  255. 'torevid' => '{{REPL:revB2}}',
  256. 'tons' => 0,
  257. 'totitle' => 'ApiComparePagesTest B',
  258. 'totexthidden' => true,
  259. 'touserhidden' => true,
  260. 'tocommenthidden' => true,
  261. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  262. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  263. . '<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",
  264. ]
  265. ],
  266. false, true
  267. ],
  268. 'Basic diff, text' => [
  269. [
  270. 'fromslots' => 'main',
  271. 'fromtext-main' => 'From text',
  272. 'fromcontentmodel-main' => 'wikitext',
  273. 'toslots' => 'main',
  274. 'totext-main' => 'To text {{subst:PAGENAME}}',
  275. 'tocontentmodel-main' => 'wikitext',
  276. ],
  277. [
  278. 'compare' => [
  279. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  280. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  281. . '<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",
  282. ]
  283. ],
  284. ],
  285. 'Basic diff, text 2' => [
  286. [
  287. 'fromslots' => 'main',
  288. 'fromtext-main' => 'From text',
  289. 'toslots' => 'main',
  290. 'totext-main' => 'To text {{subst:PAGENAME}}',
  291. 'tocontentmodel-main' => 'wikitext',
  292. ],
  293. [
  294. 'compare' => [
  295. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  296. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  297. . '<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",
  298. ]
  299. ],
  300. ],
  301. 'Basic diff, guessed model' => [
  302. [
  303. 'fromslots' => 'main',
  304. 'fromtext-main' => 'From text',
  305. 'toslots' => 'main',
  306. 'totext-main' => 'To text',
  307. ],
  308. [
  309. 'warnings' => [ [ 'code' => 'compare-nocontentmodel', 'module' => 'compare' ] ],
  310. 'compare' => [
  311. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  312. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  313. . '<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",
  314. ]
  315. ],
  316. ],
  317. 'Basic diff, text with title and PST' => [
  318. [
  319. 'fromslots' => 'main',
  320. 'fromtext-main' => 'From text',
  321. 'totitle' => 'Test',
  322. 'toslots' => 'main',
  323. 'totext-main' => 'To text {{subst:PAGENAME}}',
  324. 'topst' => true,
  325. ],
  326. [
  327. 'compare' => [
  328. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  329. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  330. . '<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",
  331. ]
  332. ],
  333. ],
  334. 'Basic diff, text with page ID and PST' => [
  335. [
  336. 'fromslots' => 'main',
  337. 'fromtext-main' => 'From text',
  338. 'toid' => '{{REPL:pageB}}',
  339. 'toslots' => 'main',
  340. 'totext-main' => 'To text {{subst:PAGENAME}}',
  341. 'topst' => true,
  342. ],
  343. [
  344. 'compare' => [
  345. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  346. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  347. . '<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",
  348. ]
  349. ],
  350. ],
  351. 'Basic diff, text with revision and PST' => [
  352. [
  353. 'fromslots' => 'main',
  354. 'fromtext-main' => 'From text',
  355. 'torev' => '{{REPL:revB2}}',
  356. 'toslots' => 'main',
  357. 'totext-main' => 'To text {{subst:PAGENAME}}',
  358. 'topst' => true,
  359. ],
  360. [
  361. 'compare' => [
  362. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  363. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  364. . '<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",
  365. ]
  366. ],
  367. ],
  368. 'Basic diff, text with deleted revision and PST' => [
  369. [
  370. 'fromslots' => 'main',
  371. 'fromtext-main' => 'From text',
  372. 'torev' => '{{REPL:revC2}}',
  373. 'toslots' => 'main',
  374. 'totext-main' => 'To text {{subst:PAGENAME}}',
  375. 'topst' => true,
  376. ],
  377. [
  378. 'compare' => [
  379. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  380. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  381. . '<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",
  382. ]
  383. ],
  384. false, true
  385. ],
  386. 'Basic diff, test with sections' => [
  387. [
  388. 'fromtitle' => 'ApiComparePagesTest F',
  389. 'fromslots' => 'main',
  390. 'fromtext-main' => "== Section 2 ==\nFrom text?",
  391. 'fromsection-main' => 2,
  392. 'totitle' => 'ApiComparePagesTest F',
  393. 'toslots' => 'main',
  394. 'totext-main' => "== Section 1 ==\nTo text?",
  395. 'tosection-main' => 1,
  396. ],
  397. [
  398. 'compare' => [
  399. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  400. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  401. . '<tr><td class=\'diff-marker\'> </td><td class=\'diff-context\'><div>== Section 1 ==</div></td><td class=\'diff-marker\'> </td><td class=\'diff-context\'><div>== Section 1 ==</div></td></tr>' . "\n"
  402. . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">F 1.1</del></div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">To text?</ins></div></td></tr>' . "\n"
  403. . '<tr><td class=\'diff-marker\'> </td><td class=\'diff-context\'></td><td class=\'diff-marker\'> </td><td class=\'diff-context\'></td></tr>' . "\n"
  404. . '<tr><td class=\'diff-marker\'> </td><td class=\'diff-context\'><div>== Section 2 ==</div></td><td class=\'diff-marker\'> </td><td class=\'diff-context\'><div>== Section 2 ==</div></td></tr>' . "\n"
  405. . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">From text?</del></div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">F 1.2</ins></div></td></tr>' . "\n",
  406. ]
  407. ],
  408. ],
  409. 'Diff with all props' => [
  410. [
  411. 'fromrev' => '{{REPL:revB1}}',
  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:revB1}}',
  420. 'fromns' => 0,
  421. 'fromtitle' => 'ApiComparePagesTest B',
  422. 'fromsize' => 3,
  423. 'fromuser' => '{{REPL:creator}}',
  424. 'fromuserid' => '{{REPL:creatorid}}',
  425. 'fromcomment' => 'Test for ApiComparePagesTest: B 1',
  426. 'fromparsedcomment' => 'Test for ApiComparePagesTest: B 1',
  427. 'toid' => '{{REPL:pageB}}',
  428. 'torevid' => '{{REPL:revB3}}',
  429. 'tons' => 0,
  430. 'totitle' => 'ApiComparePagesTest B',
  431. 'tosize' => 3,
  432. 'touserhidden' => true,
  433. 'tocommenthidden' => true,
  434. 'tosuppressed' => true,
  435. 'next' => '{{REPL:revB4}}',
  436. 'diffsize' => 391,
  437. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  438. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  439. . '<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",
  440. ]
  441. ],
  442. ],
  443. 'Diff with all props as sysop' => [
  444. [
  445. 'fromrev' => '{{REPL:revB2}}',
  446. 'torev' => '{{REPL:revB3}}',
  447. 'totitle' => 'ApiComparePagesTest B',
  448. 'prop' => 'diff|diffsize|rel|ids|title|user|comment|parsedcomment|size'
  449. ],
  450. [
  451. 'compare' => [
  452. 'fromid' => '{{REPL:pageB}}',
  453. 'fromrevid' => '{{REPL:revB2}}',
  454. 'fromns' => 0,
  455. 'fromtitle' => 'ApiComparePagesTest B',
  456. 'fromsize' => 3,
  457. 'fromtexthidden' => true,
  458. 'fromuserhidden' => true,
  459. 'fromuser' => '{{REPL:creator}}',
  460. 'fromuserid' => '{{REPL:creatorid}}',
  461. 'fromcommenthidden' => true,
  462. 'fromcomment' => 'Test for ApiComparePagesTest: B 2',
  463. 'fromparsedcomment' => 'Test for ApiComparePagesTest: B 2',
  464. 'toid' => '{{REPL:pageB}}',
  465. 'torevid' => '{{REPL:revB3}}',
  466. 'tons' => 0,
  467. 'totitle' => 'ApiComparePagesTest B',
  468. 'tosize' => 3,
  469. 'touserhidden' => true,
  470. 'tocommenthidden' => true,
  471. 'tosuppressed' => true,
  472. 'prev' => '{{REPL:revB1}}',
  473. 'next' => '{{REPL:revB4}}',
  474. 'diffsize' => 391,
  475. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  476. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  477. . '<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",
  478. ]
  479. ],
  480. false, true
  481. ],
  482. 'Relative diff, cur' => [
  483. [
  484. 'fromrev' => '{{REPL:revA2}}',
  485. 'torelative' => 'cur',
  486. 'prop' => 'ids',
  487. ],
  488. [
  489. 'compare' => [
  490. 'fromid' => '{{REPL:pageA}}',
  491. 'fromrevid' => '{{REPL:revA2}}',
  492. 'toid' => '{{REPL:pageA}}',
  493. 'torevid' => '{{REPL:revA4}}',
  494. ]
  495. ],
  496. ],
  497. 'Relative diff, next' => [
  498. [
  499. 'fromrev' => '{{REPL:revE2}}',
  500. 'torelative' => 'next',
  501. 'prop' => 'ids|rel',
  502. ],
  503. [
  504. 'compare' => [
  505. 'fromid' => '{{REPL:pageE}}',
  506. 'fromrevid' => '{{REPL:revE2}}',
  507. 'toid' => '{{REPL:pageE}}',
  508. 'torevid' => '{{REPL:revE3}}',
  509. 'prev' => '{{REPL:revE1}}',
  510. 'next' => '{{REPL:revE4}}',
  511. ]
  512. ],
  513. ],
  514. 'Relative diff, prev' => [
  515. [
  516. 'fromrev' => '{{REPL:revE3}}',
  517. 'torelative' => 'prev',
  518. 'prop' => 'ids|rel',
  519. ],
  520. [
  521. 'compare' => [
  522. 'fromid' => '{{REPL:pageE}}',
  523. 'fromrevid' => '{{REPL:revE2}}',
  524. 'toid' => '{{REPL:pageE}}',
  525. 'torevid' => '{{REPL:revE3}}',
  526. 'prev' => '{{REPL:revE1}}',
  527. 'next' => '{{REPL:revE4}}',
  528. ]
  529. ],
  530. ],
  531. 'Diff for specific slots' => [
  532. // @todo Use a page with multiple slots here
  533. [
  534. 'fromrev' => '{{REPL:revA1}}',
  535. 'torev' => '{{REPL:revA3}}',
  536. 'prop' => 'diff',
  537. 'slots' => 'main',
  538. ],
  539. [
  540. 'compare' => [
  541. 'bodies' => [
  542. 'main' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  543. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  544. . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div>A <del class="diffchange diffchange-inline">1</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",
  545. ],
  546. ],
  547. ],
  548. ],
  549. // @todo Add a test for diffing with a deleted slot. Deleting 'main' doesn't work.
  550. 'Basic diff, deprecated text' => [
  551. [
  552. 'fromtext' => 'From text',
  553. 'fromcontentmodel' => 'wikitext',
  554. 'totext' => 'To text {{subst:PAGENAME}}',
  555. 'tocontentmodel' => 'wikitext',
  556. ],
  557. [
  558. 'warnings' => self::makeDeprecationWarnings( 'fromtext', 'fromcontentmodel', 'totext', 'tocontentmodel' ),
  559. 'compare' => [
  560. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  561. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  562. . '<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",
  563. ]
  564. ],
  565. ],
  566. 'Basic diff, deprecated text 2' => [
  567. [
  568. 'fromtext' => 'From text',
  569. 'totext' => 'To text {{subst:PAGENAME}}',
  570. 'tocontentmodel' => 'wikitext',
  571. ],
  572. [
  573. 'warnings' => self::makeDeprecationWarnings( 'fromtext', 'totext', 'tocontentmodel' ),
  574. 'compare' => [
  575. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  576. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  577. . '<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",
  578. ]
  579. ],
  580. ],
  581. 'Basic diff, deprecated text, guessed model' => [
  582. [
  583. 'fromtext' => 'From text',
  584. 'totext' => 'To text',
  585. ],
  586. [
  587. 'warnings' => array_merge( self::makeDeprecationWarnings( 'fromtext', 'totext' ), [
  588. [ 'code' => 'compare-nocontentmodel', 'module' => 'compare' ],
  589. ] ),
  590. 'compare' => [
  591. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  592. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  593. . '<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",
  594. ]
  595. ],
  596. ],
  597. 'Basic diff, deprecated text with title and PST' => [
  598. [
  599. 'fromtext' => 'From text',
  600. 'totitle' => 'Test',
  601. 'totext' => 'To text {{subst:PAGENAME}}',
  602. 'topst' => true,
  603. ],
  604. [
  605. 'warnings' => self::makeDeprecationWarnings( 'fromtext', 'totext' ),
  606. 'compare' => [
  607. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  608. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  609. . '<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",
  610. ]
  611. ],
  612. ],
  613. 'Basic diff, deprecated text with page ID and PST' => [
  614. [
  615. 'fromtext' => 'From text',
  616. 'toid' => '{{REPL:pageB}}',
  617. 'totext' => 'To text {{subst:PAGENAME}}',
  618. 'topst' => true,
  619. ],
  620. [
  621. 'warnings' => self::makeDeprecationWarnings( 'fromtext', 'totext' ),
  622. 'compare' => [
  623. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  624. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  625. . '<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",
  626. ]
  627. ],
  628. ],
  629. 'Basic diff, deprecated text with revision and PST' => [
  630. [
  631. 'fromtext' => 'From text',
  632. 'torev' => '{{REPL:revB2}}',
  633. 'totext' => 'To text {{subst:PAGENAME}}',
  634. 'topst' => true,
  635. ],
  636. [
  637. 'warnings' => self::makeDeprecationWarnings( 'fromtext', 'totext' ),
  638. 'compare' => [
  639. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  640. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  641. . '<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",
  642. ]
  643. ],
  644. ],
  645. 'Basic diff, deprecated text with deleted revision and PST' => [
  646. [
  647. 'fromtext' => 'From text',
  648. 'torev' => '{{REPL:revC2}}',
  649. 'totext' => 'To text {{subst:PAGENAME}}',
  650. 'topst' => true,
  651. ],
  652. [
  653. 'warnings' => self::makeDeprecationWarnings( 'fromtext', 'totext' ),
  654. 'compare' => [
  655. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  656. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  657. . '<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",
  658. ]
  659. ],
  660. false, true
  661. ],
  662. 'Basic diff, test with deprecated sections' => [
  663. [
  664. 'fromtitle' => 'ApiComparePagesTest F',
  665. 'fromsection' => 1,
  666. 'totext' => "== Section 1 ==\nTo text\n\n== Section 2 ==\nTo text?",
  667. 'tosection' => 2,
  668. ],
  669. [
  670. 'warnings' => self::makeDeprecationWarnings( 'fromsection', 'totext', 'tosection' ),
  671. 'compare' => [
  672. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  673. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  674. . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div>== Section <del class="diffchange diffchange-inline">1 </del>==</div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div>== Section <ins class="diffchange diffchange-inline">2 </ins>==</div></td></tr>' . "\n"
  675. . '<tr><td class=\'diff-marker\'>−</td><td class=\'diff-deletedline\'><div><del class="diffchange diffchange-inline">F 1.1</del></div></td><td class=\'diff-marker\'>+</td><td class=\'diff-addedline\'><div><ins class="diffchange diffchange-inline">To text?</ins></div></td></tr>' . "\n",
  676. 'fromid' => '{{REPL:pageF}}',
  677. 'fromrevid' => '{{REPL:revF1}}',
  678. 'fromns' => '0',
  679. 'fromtitle' => 'ApiComparePagesTest F',
  680. ]
  681. ],
  682. ],
  683. 'Basic diff, test with deprecated sections and revdel, non-sysop' => [
  684. [
  685. 'fromrev' => '{{REPL:revB2}}',
  686. 'fromsection' => 0,
  687. 'torev' => '{{REPL:revB4}}',
  688. 'tosection' => 0,
  689. ],
  690. [],
  691. 'missingcontent'
  692. ],
  693. 'Basic diff, test with deprecated sections and revdel, sysop' => [
  694. [
  695. 'fromrev' => '{{REPL:revB2}}',
  696. 'fromsection' => 0,
  697. 'torev' => '{{REPL:revB4}}',
  698. 'tosection' => 0,
  699. ],
  700. [
  701. 'warnings' => self::makeDeprecationWarnings( 'fromsection', 'tosection' ),
  702. 'compare' => [
  703. 'body' => '<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>' . "\n"
  704. . '<td colspan="2" class="diff-lineno">Line 1:</td></tr>' . "\n"
  705. . '<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">4</ins></div></td></tr>' . "\n",
  706. 'fromid' => '{{REPL:pageB}}',
  707. 'fromrevid' => '{{REPL:revB2}}',
  708. 'fromns' => 0,
  709. 'fromtitle' => 'ApiComparePagesTest B',
  710. 'fromtexthidden' => true,
  711. 'fromuserhidden' => true,
  712. 'fromcommenthidden' => true,
  713. 'toid' => '{{REPL:pageB}}',
  714. 'torevid' => '{{REPL:revB4}}',
  715. 'tons' => 0,
  716. 'totitle' => 'ApiComparePagesTest B',
  717. ]
  718. ],
  719. false, true,
  720. ],
  721. 'Error, missing title' => [
  722. [
  723. 'fromtitle' => 'ApiComparePagesTest X',
  724. 'totitle' => 'ApiComparePagesTest B',
  725. ],
  726. [],
  727. 'missingtitle',
  728. ],
  729. 'Error, invalid title' => [
  730. [
  731. 'fromtitle' => '<bad>',
  732. 'totitle' => 'ApiComparePagesTest B',
  733. ],
  734. [],
  735. 'invalidtitle',
  736. ],
  737. 'Error, missing page ID' => [
  738. [
  739. 'fromid' => 8817900,
  740. 'totitle' => 'ApiComparePagesTest B',
  741. ],
  742. [],
  743. 'nosuchpageid',
  744. ],
  745. 'Error, page with missing revision' => [
  746. [
  747. 'fromtitle' => 'ApiComparePagesTest D',
  748. 'totitle' => 'ApiComparePagesTest B',
  749. ],
  750. [],
  751. 'nosuchrevid',
  752. ],
  753. 'Error, page with no revision' => [
  754. [
  755. 'fromtitle' => 'ApiComparePagesTest E',
  756. 'totitle' => 'ApiComparePagesTest B',
  757. ],
  758. [],
  759. 'nosuchrevid',
  760. ],
  761. 'Error, bad rev ID' => [
  762. [
  763. 'fromrev' => 8817900,
  764. 'totitle' => 'ApiComparePagesTest B',
  765. ],
  766. [],
  767. 'nosuchrevid',
  768. ],
  769. 'Error, deleted revision ID, non-sysop' => [
  770. [
  771. 'fromrev' => '{{REPL:revA2}}',
  772. 'torev' => '{{REPL:revC2}}',
  773. ],
  774. [],
  775. 'nosuchrevid',
  776. ],
  777. 'Error, revision-deleted content' => [
  778. [
  779. 'fromrev' => '{{REPL:revA2}}',
  780. 'torev' => '{{REPL:revB2}}',
  781. ],
  782. [],
  783. 'missingcontent',
  784. ],
  785. 'Error, text with no title and PST' => [
  786. [
  787. 'fromtext' => 'From text',
  788. 'totext' => 'To text {{subst:PAGENAME}}',
  789. 'topst' => true,
  790. ],
  791. [],
  792. 'compare-no-title',
  793. ],
  794. 'Error, test with invalid from section ID' => [
  795. [
  796. 'fromtitle' => 'ApiComparePagesTest F',
  797. 'fromsection' => 5,
  798. 'totext' => "== Section 1 ==\nTo text\n\n== Section 2 ==\nTo text?",
  799. 'tosection' => 2,
  800. ],
  801. [],
  802. 'nosuchfromsection',
  803. ],
  804. 'Error, test with invalid to section ID' => [
  805. [
  806. 'fromtitle' => 'ApiComparePagesTest F',
  807. 'fromsection' => 1,
  808. 'totext' => "== Section 1 ==\nTo text\n\n== Section 2 ==\nTo text?",
  809. 'tosection' => 5,
  810. ],
  811. [],
  812. 'nosuchtosection',
  813. ],
  814. 'Error, Relative diff, no from revision' => [
  815. [
  816. 'fromtext' => 'Foo',
  817. 'torelative' => 'cur',
  818. 'prop' => 'ids',
  819. ],
  820. [],
  821. 'compare-relative-to-nothing'
  822. ],
  823. 'Error, Relative diff, cur with no current revision' => [
  824. [
  825. 'fromrev' => '{{REPL:revE2}}',
  826. 'torelative' => 'cur',
  827. 'prop' => 'ids',
  828. ],
  829. [],
  830. 'nosuchrevid'
  831. ],
  832. 'Error, Relative diff, next revdeleted' => [
  833. [
  834. 'fromrev' => '{{REPL:revB1}}',
  835. 'torelative' => 'next',
  836. 'prop' => 'ids',
  837. ],
  838. [],
  839. 'missingcontent'
  840. ],
  841. 'Error, Relative diff, prev revdeleted' => [
  842. [
  843. 'fromrev' => '{{REPL:revB3}}',
  844. 'torelative' => 'prev',
  845. 'prop' => 'ids',
  846. ],
  847. [],
  848. 'missingcontent'
  849. ],
  850. 'Error, Relative diff, no prev' => [
  851. [
  852. 'fromrev' => '{{REPL:revA1}}',
  853. 'torelative' => 'prev',
  854. 'prop' => 'ids',
  855. ],
  856. [],
  857. 'baddiff'
  858. ],
  859. 'Error, Relative diff, no next' => [
  860. [
  861. 'fromrev' => '{{REPL:revA4}}',
  862. 'torelative' => 'next',
  863. 'prop' => 'ids',
  864. ],
  865. [],
  866. 'baddiff'
  867. ],
  868. 'Error, section diff with no revision' => [
  869. [
  870. 'fromtitle' => 'ApiComparePagesTest F',
  871. 'toslots' => 'main',
  872. 'totext-main' => "== Section 1 ==\nTo text?",
  873. 'tosection-main' => 1,
  874. ],
  875. [],
  876. 'compare-notorevision',
  877. ],
  878. 'Error, section diff with revdeleted revision' => [
  879. [
  880. 'fromtitle' => 'ApiComparePagesTest F',
  881. 'torev' => '{{REPL:revB2}}',
  882. 'toslots' => 'main',
  883. 'totext-main' => "== Section 1 ==\nTo text?",
  884. 'tosection-main' => 1,
  885. ],
  886. [],
  887. 'missingcontent',
  888. ],
  889. 'Error, section diff with a content model not supporting sections' => [
  890. [
  891. 'fromtitle' => 'ApiComparePagesTest G',
  892. 'torev' => '{{REPL:revG1}}',
  893. 'toslots' => 'main',
  894. 'totext-main' => "== Section 1 ==\nTo text?",
  895. 'tosection-main' => 1,
  896. ],
  897. [],
  898. 'sectionsnotsupported',
  899. ],
  900. 'Error, section diff with bad content model' => [
  901. [
  902. 'fromtitle' => 'ApiComparePagesTest F',
  903. 'torev' => '{{REPL:revF1}}',
  904. 'toslots' => 'main',
  905. 'totext-main' => "== Section 1 ==\nTo text?",
  906. 'tosection-main' => 1,
  907. 'tocontentmodel-main' => CONTENT_MODEL_TEXT,
  908. ],
  909. [],
  910. 'sectionreplacefailed',
  911. ],
  912. 'Error, deleting the main slot' => [
  913. [
  914. 'fromtitle' => 'ApiComparePagesTest A',
  915. 'totitle' => 'ApiComparePagesTest A',
  916. 'toslots' => 'main',
  917. ],
  918. [],
  919. 'compare-maintextrequired',
  920. ],
  921. // @todo Add a test for using 'tosection-foo' without 'totext-foo' (can't do it with main)
  922. ];
  923. // phpcs:enable
  924. }
  925. }