Merge "Avoid rebuilding database fixtures for every test run"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 11 Mar 2016 00:06:19 +0000 (00:06 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 11 Mar 2016 00:06:19 +0000 (00:06 +0000)
20 files changed:
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/BlockTest.php
tests/phpunit/includes/MergeHistoryTest.php
tests/phpunit/includes/PrefixSearchTest.php
tests/phpunit/includes/RevisionStorageTest.php
tests/phpunit/includes/api/ApiBlockTest.php
tests/phpunit/includes/api/query/ApiQueryBasicTest.php
tests/phpunit/includes/api/query/ApiQueryContinue2Test.php
tests/phpunit/includes/api/query/ApiQueryContinueTest.php
tests/phpunit/includes/cache/GenderCacheTest.php
tests/phpunit/includes/cache/MessageCacheTest.php
tests/phpunit/includes/changes/CategoryMembershipChangeTest.php
tests/phpunit/includes/db/DatabaseSqliteTest.php
tests/phpunit/includes/deferred/LinksUpdateTest.php
tests/phpunit/includes/jobqueue/jobs/CategoryMembershipChangeJobTest.php
tests/phpunit/includes/parser/NewParserTest.php
tests/phpunit/includes/search/SearchEnginePrefixTest.php
tests/phpunit/includes/search/SearchEngineTest.php
tests/phpunit/includes/session/BotPasswordSessionProviderTest.php
tests/phpunit/includes/specials/SpecialMyLanguageTest.php

index 3bd5ed8..b9cf51d 100644 (file)
@@ -134,12 +134,20 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                        if ( !self::$dbSetup ) {
                                // switch to a temporary clone of the database
                                self::setupTestDB( $this->db, $this->dbPrefix() );
+                               $this->addCoreDBData();
 
                                if ( ( $this->db->getType() == 'oracle' || !self::$useTemporaryTables ) && self::$reuseDB ) {
                                        $this->resetDB();
                                }
                        }
-                       $this->addCoreDBData();
+
+                       // TODO: the DB setup should be done in setUpBeforeClass(), so the test DB
+                       // is available in subclasse's setUpBeforeClass() and setUp() methods.
+                       // This would also remove the need for the HACK that is oncePerClass().
+                       if ( $this->oncePerClass() ) {
+                               $this->addDBDataOnce();
+                       }
+
                        $this->addDBData();
                        $needsResetDB = true;
                }
@@ -151,6 +159,22 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                }
        }
 
+       /**
+        * @return boolean
+        */
+       private function oncePerClass() {
+               // Remember current test class in the database connection,
+               // so we know when we need to run addData.
+
+               $class = static::class;
+
+               $first = !isset( $this->db->_hasDataForTestClass )
+                       || $this->db->_hasDataForTestClass !== $class;
+
+               $this->db->_hasDataForTestClass = $class;
+               return $first;
+       }
+
        /**
         * @since 1.21
         *
@@ -554,8 +578,29 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
        }
 
        /**
-        * Stub. If a test needs to add additional data to the database, it should
-        * implement this method and do so
+        * Stub. If a test suite needs to add additional data to the database, it should
+        * implement this method and do so. This method is called once per test suite
+        * (i.e. once per class).
+        *
+        * Note data added by this method may be removed by resetDB() depending on
+        * the contents of $tablesUsed.
+        *
+        * To add additional data between test function runs, override prepareDB().
+        *
+        * @see addDBData()
+        * @see resetDB()
+        *
+        * @since 1.27
+        */
+       public function addDBDataOnce() {
+       }
+
+       /**
+        * Stub. Subclasses may override this to prepare the database.
+        * Called before every test run (test function or data set).
+        *
+        * @see addDBDataOnce()
+        * @see resetDB()
         *
         * @since 1.18
         */
@@ -702,23 +747,16 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
         */
        private function resetDB() {
                if ( $this->db ) {
-                       if ( $this->db->getType() == 'oracle' ) {
-                               if ( self::$useTemporaryTables ) {
-                                       wfGetLB()->closeAll();
-                                       $this->db = wfGetDB( DB_MASTER );
-                               } else {
-                                       foreach ( $this->tablesUsed as $tbl ) {
-                                               if ( $tbl == 'interwiki' ) {
-                                                       continue;
-                                               }
-                                               $this->db->query( 'TRUNCATE TABLE ' . $this->db->tableName( $tbl ), __METHOD__ );
-                                       }
+                       $truncate = in_array( $this->db->getType(), [ 'oracle', 'mysql' ] );
+                       foreach ( $this->tablesUsed as $tbl ) {
+                               // TODO: reset interwiki and user tables to their original content.
+                               if ( $tbl == 'interwiki' || $tbl == 'user' ) {
+                                       continue;
                                }
-                       } else {
-                               foreach ( $this->tablesUsed as $tbl ) {
-                                       if ( $tbl == 'interwiki' || $tbl == 'user' ) {
-                                               continue;
-                                       }
+
+                               if ( $truncate ) {
+                                       $this->db->query( 'TRUNCATE TABLE ' . $this->db->tableName( $tbl ), __METHOD__ );
+                               } else {
                                        $this->db->delete( $tbl, '*', __METHOD__ );
                                }
                        }
@@ -1310,4 +1348,5 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
        public static function wfResetOutputBuffersBarrier( $buffer ) {
                return $buffer;
        }
+
 }
index e14960a..35ebf42 100644 (file)
@@ -14,7 +14,6 @@ class BlockTest extends MediaWikiLangTestCase {
        private $blockId;
 
        function addDBData() {
-
                $user = User::newFromName( 'UTBlockee' );
                if ( $user->getID() == 0 ) {
                        $user->addToDatabase();
index 951cf8d..5ea0cdf 100644 (file)
@@ -8,7 +8,7 @@ class MergeHistoryTest extends MediaWikiTestCase {
        /**
         * Make some pages to work with
         */
-       public function addDBData() {
+       public function addDBDataOnce() {
                // Pages that won't actually be merged
                $this->insertPage( 'Test' );
                $this->insertPage( 'Test2' );
index 6f4c300..6d5154f 100644 (file)
@@ -5,7 +5,7 @@
  */
 class PrefixSearchTest extends MediaWikiLangTestCase {
 
-       public function addDBData() {
+       public function addDBDataOnce() {
                if ( !$this->isWikitextNS( NS_MAIN ) ) {
                        // tests are skipped if NS_MAIN is not wikitext
                        return;
index 16d8c97..440495b 100644 (file)
@@ -57,6 +57,8 @@ class RevisionStorageTest extends MediaWikiTestCase {
                                CONTENT_MODEL_WIKITEXT
                        );
                }
+
+               $this->tablesUsed[] = 'archive';
        }
 
        protected function tearDown() {
index f51997c..d2dccf9 100644 (file)
@@ -17,7 +17,7 @@ class ApiBlockTest extends ApiTestCase {
                return $this->getTokenList( self::$users['sysop'] );
        }
 
-       function addDBData() {
+       function addDBDataOnce() {
                $user = User::newFromName( 'UTApiBlockee' );
 
                if ( $user->getId() == 0 ) {
index 9ba4587..e5971b4 100644 (file)
@@ -36,9 +36,10 @@ class ApiQueryBasicTest extends ApiQueryTestBase {
 
        /**
         * Create a set of pages. These must not change, otherwise the tests might give wrong results.
-        * @see MediaWikiTestCase::addDBData()
+        *
+*@see MediaWikiTestCase::addDBDataOnce()
         */
-       function addDBData() {
+       function addDBDataOnce() {
                try {
                        if ( Title::newFromText( 'AQBT-All' )->exists() ) {
                                return;
index 8f11a51..944d31c 100644 (file)
@@ -29,9 +29,10 @@ class ApiQueryContinue2Test extends ApiQueryContinueTestBase {
 
        /**
         * Create a set of pages. These must not change, otherwise the tests might give wrong results.
-        * @see MediaWikiTestCase::addDBData()
+        *
+*@see MediaWikiTestCase::addDBDataOnce()
         */
-       function addDBData() {
+       function addDBDataOnce() {
                try {
                        $this->editPage( 'AQCT73462-A', '**AQCT73462-A**  [[AQCT73462-B]] [[AQCT73462-C]]' );
                        $this->editPage( 'AQCT73462-B', '[[AQCT73462-A]]  **AQCT73462-B** [[AQCT73462-C]]' );
index a6269ed..b31627b 100644 (file)
@@ -33,9 +33,10 @@ class ApiQueryContinueTest extends ApiQueryContinueTestBase {
 
        /**
         * Create a set of pages. These must not change, otherwise the tests might give wrong results.
-        * @see MediaWikiTestCase::addDBData()
+        *
+*@see MediaWikiTestCase::addDBDataOnce()
         */
-       function addDBData() {
+       function addDBDataOnce() {
                try {
                        $this->editPage( 'Template:AQCT-T1', '**Template:AQCT-T1**' );
                        $this->editPage( 'Template:AQCT-T2', '**Template:AQCT-T2**' );
index a441b3d..40994da 100644 (file)
@@ -6,7 +6,7 @@
  */
 class GenderCacheTest extends MediaWikiLangTestCase {
 
-       function addDBData() {
+       function addDBDataOnce() {
                // ensure the correct default gender
                $this->mergeMwGlobalArrayValue( 'wgDefaultUserOptions', [ 'gender' => 'unknown' ] );
 
index 38cc863..bd744c0 100644 (file)
@@ -23,7 +23,7 @@ class MessageCacheTest extends MediaWikiLangTestCase {
                $this->setContentLang( 'de' );
        }
 
-       function addDBData() {
+       function addDBDataOnce() {
                $this->configureLanguages();
 
                // Set up messages and fallbacks ab -> ru -> de
index 70da12e..6369b33 100644 (file)
@@ -24,6 +24,16 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase {
         */
        private static $mockRecentChange;
 
+       /**
+        * @var Revision
+        */
+       private static $pageRev = null;
+
+       /**
+        * @var string
+        */
+       private static $pageName = 'CategoryMembershipChangeTestPage';
+
        public static function newForCategorizationCallback() {
                self::$lastNotifyArgs = func_get_args();
                self::$notifyCallCounter += 1;
@@ -34,10 +44,20 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase {
                parent::setUp();
                self::$notifyCallCounter = 0;
                self::$mockRecentChange = self::getMock( 'RecentChange' );
+
+               $this->setContentLang( 'qqx' );
+       }
+
+       public function addDBDataOnce() {
+               $info = $this->insertPage( self::$pageName );
+               $title = $info['title'];
+
+               $page = WikiPage::factory( $title );
+               self::$pageRev = $page->getRevision();
        }
 
        private function newChange( Revision $revision = null ) {
-               $change = new CategoryMembershipChange( Title::newFromText( 'UTPage' ), $revision );
+               $change = new CategoryMembershipChange( Title::newFromText( self::$pageName ), $revision );
                $change->overrideNewForCategorizationCallback(
                        'CategoryMembershipChangeTest::newForCategorizationCallback'
                );
@@ -53,9 +73,10 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase {
 
                $this->assertTrue( strlen( self::$lastNotifyArgs[0] ) === 14 );
                $this->assertEquals( 'Category:CategoryName', self::$lastNotifyArgs[1]->getPrefixedText() );
-               $this->assertEquals( 'MediaWiki automatic change', self::$lastNotifyArgs[2]->getName() );
-               $this->assertEquals( '[[:UTPage]] added to category', self::$lastNotifyArgs[3] );
-               $this->assertEquals( 'UTPage', self::$lastNotifyArgs[4]->getPrefixedText() );
+               $this->assertEquals( '(autochange-username)', self::$lastNotifyArgs[2]->getName() );
+               $this->assertEquals( '(recentchanges-page-added-to-category: ' . self::$pageName . ', 0)',
+                       self::$lastNotifyArgs[3] );
+               $this->assertEquals( self::$pageName, self::$lastNotifyArgs[4]->getPrefixedText() );
                $this->assertEquals( 0, self::$lastNotifyArgs[5] );
                $this->assertEquals( 0, self::$lastNotifyArgs[6] );
                $this->assertEquals( null, self::$lastNotifyArgs[7] );
@@ -72,9 +93,10 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase {
 
                $this->assertTrue( strlen( self::$lastNotifyArgs[0] ) === 14 );
                $this->assertEquals( 'Category:CategoryName', self::$lastNotifyArgs[1]->getPrefixedText() );
-               $this->assertEquals( 'MediaWiki automatic change', self::$lastNotifyArgs[2]->getName() );
-               $this->assertEquals( '[[:UTPage]] removed from category', self::$lastNotifyArgs[3] );
-               $this->assertEquals( 'UTPage', self::$lastNotifyArgs[4]->getPrefixedText() );
+               $this->assertEquals( '(autochange-username)', self::$lastNotifyArgs[2]->getName() );
+               $this->assertEquals( '(recentchanges-page-removed-from-category: ' . self::$pageName . ', 0)',
+                       self::$lastNotifyArgs[3] );
+               $this->assertEquals( self::$pageName, self::$lastNotifyArgs[4]->getPrefixedText() );
                $this->assertEquals( 0, self::$lastNotifyArgs[5] );
                $this->assertEquals( 0, self::$lastNotifyArgs[6] );
                $this->assertEquals( null, self::$lastNotifyArgs[7] );
@@ -84,7 +106,7 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase {
        }
 
        public function testChangeAddedWithRev() {
-               $revision = Revision::newFromId( Title::newFromText( 'UTPage' )->getLatestRevID() );
+               $revision = Revision::newFromId( Title::newFromText( self::$pageName )->getLatestRevID() );
                $change = $this->newChange( $revision );
                $change->triggerCategoryAddedNotification( Title::newFromText( 'CategoryName', NS_CATEGORY ) );
 
@@ -93,9 +115,10 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase {
                $this->assertTrue( strlen( self::$lastNotifyArgs[0] ) === 14 );
                $this->assertEquals( 'Category:CategoryName', self::$lastNotifyArgs[1]->getPrefixedText() );
                $this->assertEquals( 'UTSysop', self::$lastNotifyArgs[2]->getName() );
-               $this->assertEquals( '[[:UTPage]] added to category', self::$lastNotifyArgs[3] );
-               $this->assertEquals( 'UTPage', self::$lastNotifyArgs[4]->getPrefixedText() );
-               $this->assertEquals( 0, self::$lastNotifyArgs[5] );
+               $this->assertEquals( '(recentchanges-page-added-to-category: ' . self::$pageName . ', 0)',
+                       self::$lastNotifyArgs[3] );
+               $this->assertEquals( self::$pageName, self::$lastNotifyArgs[4]->getPrefixedText() );
+               $this->assertEquals( self::$pageRev->getParentId(), self::$lastNotifyArgs[5] );
                $this->assertEquals( $revision->getId(), self::$lastNotifyArgs[6] );
                $this->assertEquals( null, self::$lastNotifyArgs[7] );
                $this->assertEquals( 0, self::$lastNotifyArgs[8] );
@@ -104,7 +127,7 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase {
        }
 
        public function testChangeRemovedWithRev() {
-               $revision = Revision::newFromId( Title::newFromText( 'UTPage' )->getLatestRevID() );
+               $revision = Revision::newFromId( Title::newFromText( self::$pageName )->getLatestRevID() );
                $change = $this->newChange( $revision );
                $change->triggerCategoryRemovedNotification( Title::newFromText( 'CategoryName', NS_CATEGORY ) );
 
@@ -113,9 +136,10 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase {
                $this->assertTrue( strlen( self::$lastNotifyArgs[0] ) === 14 );
                $this->assertEquals( 'Category:CategoryName', self::$lastNotifyArgs[1]->getPrefixedText() );
                $this->assertEquals( 'UTSysop', self::$lastNotifyArgs[2]->getName() );
-               $this->assertEquals( '[[:UTPage]] removed from category', self::$lastNotifyArgs[3] );
-               $this->assertEquals( 'UTPage', self::$lastNotifyArgs[4]->getPrefixedText() );
-               $this->assertEquals( 0, self::$lastNotifyArgs[5] );
+               $this->assertEquals( '(recentchanges-page-removed-from-category: ' . self::$pageName . ', 0)',
+                       self::$lastNotifyArgs[3] );
+               $this->assertEquals( self::$pageName, self::$lastNotifyArgs[4]->getPrefixedText() );
+               $this->assertEquals( self::$pageRev->getParentId(), self::$lastNotifyArgs[5] );
                $this->assertEquals( $revision->getId(), self::$lastNotifyArgs[6] );
                $this->assertEquals( null, self::$lastNotifyArgs[7] );
                $this->assertEquals( 0, self::$lastNotifyArgs[8] );
index 18de9be..80fb826 100644 (file)
@@ -330,7 +330,7 @@ class DatabaseSqliteTest extends MediaWikiTestCase {
 
                foreach ( $versions as $version ) {
                        $versions = "upgrading from $version to $wgVersion";
-                       $db = $this->prepareDB( $version );
+                       $db = $this->prepareTestDB( $version );
                        $tables = $this->getTables( $db );
                        $this->assertEquals( $currentTables, $tables, "Different tables $versions" );
                        foreach ( $tables as $table ) {
@@ -389,7 +389,7 @@ class DatabaseSqliteTest extends MediaWikiTestCase {
                $this->assertTrue( $db->close(), "closing database" );
        }
 
-       private function prepareDB( $version ) {
+       private function prepareTestDB( $version ) {
                static $maint = null;
                if ( $maint === null ) {
                        $maint = new FakeMaintenance();
index 75af87e..9609f74 100644 (file)
@@ -6,7 +6,7 @@
  * ^--- make sure temporary tables are used.
  */
 class LinksUpdateTest extends MediaWikiLangTestCase {
-       protected $testingPageId;
+       protected static $testingPageId;
 
        function __construct( $name = null, array $data = [], $dataName = '' ) {
                parent::__construct( $name, $data, $dataName );
@@ -45,9 +45,9 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                $this->setMwGlobals( 'wgRCWatchCategoryMembership', true );
        }
 
-       public function addDBData() {
+       public function addDBDataOnce() {
                $res = $this->insertPage( 'Testing' );
-               $this->testingPageId = $res['id'];
+               self::$testingPageId = $res['id'];
                $this->insertPage( 'Some_other_page' );
                $this->insertPage( 'Template:TestingTemplate' );
        }
@@ -68,7 +68,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
        public function testUpdate_pagelinks() {
                /** @var Title $t */
                /** @var ParserOutput $po */
-               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
 
                $po->addLink( Title::newFromText( "Foo" ) );
                $po->addLink( Title::newFromText( "Special:Foo" ) ); // special namespace should be ignored
@@ -81,7 +81,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                        'pagelinks',
                        'pl_namespace,
                        pl_title',
-                       'pl_from = ' . $this->testingPageId,
+                       'pl_from = ' . self::$testingPageId,
                        [ [ NS_MAIN, 'Foo' ] ]
                );
                $this->assertArrayEquals( [
@@ -100,7 +100,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                        'pagelinks',
                        'pl_namespace,
                        pl_title',
-                       'pl_from = ' . $this->testingPageId,
+                       'pl_from = ' . self::$testingPageId,
                        [
                                [ NS_MAIN, 'Bar' ],
                                [ NS_TALK, 'Bar' ],
@@ -120,7 +120,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
         */
        public function testUpdate_externallinks() {
                /** @var ParserOutput $po */
-               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
 
                $po->addExternalLink( "http://testing.com/wiki/Foo" );
 
@@ -129,7 +129,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                        $po,
                        'externallinks',
                        'el_to, el_index',
-                       'el_from = ' . $this->testingPageId,
+                       'el_from = ' . self::$testingPageId,
                        [
                                [ 'http://testing.com/wiki/Foo', 'http://com.testing./wiki/Foo' ],
                        ]
@@ -143,7 +143,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                /** @var ParserOutput $po */
                $this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
 
-               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
 
                $po->addCategory( "Foo", "FOO" );
 
@@ -152,7 +152,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                        $po,
                        'categorylinks',
                        'cl_to, cl_sortkey',
-                       'cl_from = ' . $this->testingPageId,
+                       'cl_from = ' . self::$testingPageId,
                        [ [ 'Foo', "FOO\nTESTING" ] ]
                );
        }
@@ -232,7 +232,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
         */
        public function testUpdate_iwlinks() {
                /** @var ParserOutput $po */
-               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
 
                $target = Title::makeTitleSafe( NS_MAIN, "Foo", '', 'linksupdatetest' );
                $po->addInterwikiLink( $target );
@@ -242,7 +242,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                        $po,
                        'iwlinks',
                        'iwl_prefix, iwl_title',
-                       'iwl_from = ' . $this->testingPageId,
+                       'iwl_from = ' . self::$testingPageId,
                        [ [ 'linksupdatetest', 'Foo' ] ]
                );
        }
@@ -252,7 +252,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
         */
        public function testUpdate_templatelinks() {
                /** @var ParserOutput $po */
-               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
 
                $po->addTemplate( Title::newFromText( "Template:Foo" ), 23, 42 );
 
@@ -262,7 +262,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                        'templatelinks',
                        'tl_namespace,
                        tl_title',
-                       'tl_from = ' . $this->testingPageId,
+                       'tl_from = ' . self::$testingPageId,
                        [ [ NS_TEMPLATE, 'Foo' ] ]
                );
        }
@@ -272,7 +272,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
         */
        public function testUpdate_imagelinks() {
                /** @var ParserOutput $po */
-               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
 
                $po->addImage( "Foo.png" );
 
@@ -281,7 +281,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                        $po,
                        'imagelinks',
                        'il_to',
-                       'il_from = ' . $this->testingPageId,
+                       'il_from = ' . self::$testingPageId,
                        [ [ 'Foo.png' ] ]
                );
        }
@@ -295,7 +295,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                ] );
 
                /** @var ParserOutput $po */
-               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
 
                $po->addLanguageLink( Title::newFromText( "en:Foo" )->getFullText() );
 
@@ -304,7 +304,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                        $po,
                        'langlinks',
                        'll_lang, ll_title',
-                       'll_from = ' . $this->testingPageId,
+                       'll_from = ' . self::$testingPageId,
                        [ [ 'En', 'Foo' ] ]
                );
        }
@@ -316,7 +316,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                global $wgPagePropsHaveSortkey;
 
                /** @var ParserOutput $po */
-               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+               list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
 
                $fields = [ 'pp_propname', 'pp_value' ];
                $expected = [];
@@ -349,7 +349,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
                }
 
                $this->assertLinksUpdate(
-                       $t, $po, 'page_props', $fields, 'pp_page = ' . $this->testingPageId, $expected );
+                       $t, $po, 'page_props', $fields, 'pp_page = ' . self::$testingPageId, $expected );
        }
 
        public function testUpdate_page_props_without_sortkey() {
index 50a24ad..54178fe 100644 (file)
@@ -21,10 +21,11 @@ class CategoryMembershipChangeJobTest extends MediaWikiTestCase {
        public function setUp() {
                parent::setUp();
                $this->setMwGlobals( 'wgRCWatchCategoryMembership', true );
+               $this->setContentLang( 'qqx' );
        }
 
-       public function addDBData() {
-               parent::addDBData();
+       public function addDBDataOnce() {
+               parent::addDBDataOnce();
                $insertResult = $this->insertPage( self::TITLE_STRING, 'UT Content' );
                $this->title = $insertResult['title'];
        }
@@ -74,11 +75,11 @@ class CategoryMembershipChangeJobTest extends MediaWikiTestCase {
                $removedRevId = $this->editPageText( 'Blank' );
 
                $this->assertEquals(
-                       '[[:' . self::TITLE_STRING . ']] added to category',
+                       '(recentchanges-page-added-to-category: ' . self::TITLE_STRING . ', 0)',
                        $this->getCategorizeRecentChangeForRevId( $addedRevId )->getAttribute( 'rc_comment' )
                );
                $this->assertEquals(
-                       '[[:' . self::TITLE_STRING . ']] removed from category',
+                       '(recentchanges-page-removed-from-category: ' . self::TITLE_STRING . ', 0)',
                        $this->getCategorizeRecentChangeForRevId( $removedRevId )->getAttribute( 'rc_comment' )
                );
        }
index 04d6067..4eb480d 100644 (file)
@@ -211,15 +211,15 @@ class NewParserTest extends MediaWikiTestCase {
                parent::tearDownAfterClass();
        }
 
-       function addDBData() {
-               $this->tablesUsed[] = 'site_stats';
+       function addDBDataOnce() {
                # disabled for performance
                # $this->tablesUsed[] = 'image';
 
                # Update certain things in site_stats
                $this->db->insert( 'site_stats',
                        [ 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ],
-                       __METHOD__
+                       __METHOD__,
+                       [ 'IGNORE' ]
                );
 
                $user = User::newFromId( 0 );
index 2a3a5fe..6a3f95b 100644 (file)
@@ -10,7 +10,7 @@ class SearchEnginePrefixTest extends MediaWikiLangTestCase {
         */
        private $search;
 
-       public function addDBData() {
+       public function addDBDataOnce() {
                if ( !$this->isWikitextNS( NS_MAIN ) ) {
                        // tests are skipped if NS_MAIN is not wikitext
                        return;
index b680d5e..055e982 100644 (file)
@@ -44,7 +44,7 @@ class SearchEngineTest extends MediaWikiLangTestCase {
                parent::tearDown();
        }
 
-       public function addDBData() {
+       public function addDBDataOnce() {
                if ( !$this->isWikitextNS( NS_MAIN ) ) {
                        // @todo cover the case of non-wikitext content in the main namespace
                        return;
index 590f287..5126a42 100644 (file)
@@ -62,7 +62,7 @@ class BotPasswordSessionProviderTest extends MediaWikiTestCase {
                ] );
        }
 
-       public function addDBData() {
+       public function addDBDataOnce() {
                $passwordFactory = new \PasswordFactory();
                $passwordFactory->init( \RequestContext::getMain()->getConfig() );
                // A is unsalted MD5 (thus fast) ... we don't care about security here, this is test only
index 548b75b..89fd1b0 100644 (file)
@@ -5,7 +5,7 @@
  * @covers SpecialMyLanguage
  */
 class SpecialMyLanguageTest extends MediaWikiTestCase {
-       public function addDBData() {
+       public function addDBDataOnce() {
                $titles = [
                        'Page/Another',
                        'Page/Another/ru',