Merge "Chinese Conversion Table Update 2017-6"
[lhc/web/wiklou.git] / tests / phpunit / includes / deferred / LinksUpdateTest.php
index ac75e55..ddc0798 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @covers LinksUpdate
  * @group LinksUpdate
  * @group Database
  * ^--- make sure temporary tables are used.
@@ -167,7 +168,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
 
                $this->assertRecentChangeByCategorization(
                        $title,
-                       $wikiPage->getParserOutput( new ParserOptions() ),
+                       $wikiPage->getParserOutput( ParserOptions::newCanonical() ),
                        Title::newFromText( 'Category:Foo' ),
                        [ [ 'Foo', '[[:Testing]] added to category' ] ]
                );
@@ -177,7 +178,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
 
                $this->assertRecentChangeByCategorization(
                        $title,
-                       $wikiPage->getParserOutput( new ParserOptions() ),
+                       $wikiPage->getParserOutput( ParserOptions::newCanonical() ),
                        Title::newFromText( 'Category:Foo' ),
                        [
                                [ 'Foo', '[[:Testing]] added to category' ],
@@ -187,7 +188,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
 
                $this->assertRecentChangeByCategorization(
                        $title,
-                       $wikiPage->getParserOutput( new ParserOptions() ),
+                       $wikiPage->getParserOutput( ParserOptions::newCanonical() ),
                        Title::newFromText( 'Category:Bar' ),
                        [
                                [ 'Bar', '[[:Testing]] added to category' ],
@@ -211,7 +212,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
 
                $this->assertRecentChangeByCategorization(
                        $templateTitle,
-                       $templatePage->getParserOutput( new ParserOptions() ),
+                       $templatePage->getParserOutput( ParserOptions::newCanonical() ),
                        Title::newFromText( 'Baz' ),
                        []
                );
@@ -221,12 +222,12 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
 
                $this->assertRecentChangeByCategorization(
                        $templateTitle,
-                       $templatePage->getParserOutput( new ParserOptions() ),
+                       $templatePage->getParserOutput( ParserOptions::newCanonical() ),
                        Title::newFromText( 'Baz' ),
                        [ [
                                'Baz',
-                               '[[:Template:TestingTemplate]] and [[Special:WhatLinksHere/Template:TestingTemplate|2 pages]] '
-                               . 'added to category'
+                               '[[:Template:TestingTemplate]] added to category, ' .
+                               '[[Special:WhatLinksHere/Template:TestingTemplate|this page is included within other pages]]'
                        ] ]
                );
        }
@@ -369,10 +370,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
        ) {
                $update = new LinksUpdate( $title, $parserOutput );
 
-               // NOTE: make sure LinksUpdate does not generate warnings when called inside a transaction.
-               $update->beginTransaction();
                $update->doUpdate();
-               $update->commitTransaction();
 
                $this->assertSelect( $table, $fields, $condition, $expectedRows );
                return $update;
@@ -381,16 +379,33 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
        protected function assertRecentChangeByCategorization(
                Title $pageTitle, ParserOutput $parserOutput, Title $categoryTitle, $expectedRows
        ) {
-               $this->assertSelect(
-                       'recentchanges',
-                       'rc_title, rc_comment',
-                       [
-                               'rc_type' => RC_CATEGORIZE,
-                               'rc_namespace' => NS_CATEGORY,
-                               'rc_title' => $categoryTitle->getDBkey()
-                       ],
-                       $expectedRows
-               );
+               global $wgCommentTableSchemaMigrationStage;
+
+               if ( $wgCommentTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ) {
+                       $this->assertSelect(
+                               'recentchanges',
+                               'rc_title, rc_comment',
+                               [
+                                       'rc_type' => RC_CATEGORIZE,
+                                       'rc_namespace' => NS_CATEGORY,
+                                       'rc_title' => $categoryTitle->getDBkey()
+                               ],
+                               $expectedRows
+                       );
+               }
+               if ( $wgCommentTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) {
+                       $this->assertSelect(
+                               [ 'recentchanges', 'comment' ],
+                               'rc_title, comment_text',
+                               [
+                                       'rc_type' => RC_CATEGORIZE,
+                                       'rc_namespace' => NS_CATEGORY,
+                                       'rc_title' => $categoryTitle->getDBkey(),
+                                       'comment_id = rc_comment_id',
+                               ],
+                               $expectedRows
+                       );
+               }
        }
 
        private function runAllRelatedJobs() {