Merge "Clarify MediaWikiTestCase::getSchemaOverrides()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 14 Jun 2019 00:06:06 +0000 (00:06 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 14 Jun 2019 00:06:06 +0000 (00:06 +0000)
1  2 
tests/phpunit/MediaWikiTestCase.php

@@@ -1596,6 -1596,10 +1596,10 @@@ abstract class MediaWikiTestCase extend
         * Stub. If a test suite needs to test against a specific database schema, it should
         * override this method and return the appropriate information from it.
         *
+        * 'create', 'drop' and 'alter' in the returned array should list all the tables affected
+        * by the 'scripts', even if the test is only interested in a subset of them, otherwise
+        * the overrides may not be fully cleaned up, leading to errors later.
+        *
         * @param IMaintainableDatabase $db The DB connection to use for the mock schema.
         *        May be used to check the current state of the schema, to determine what
         *        overrides are needed.
         * @param string $text Content of the page
         * @param string $summary Optional summary string for the revision
         * @param int $defaultNs Optional namespace id
 +       * @param User|null $user If null, static::getTestSysop()->getUser() is used.
         * @return Status Object as returned by WikiPage::doEditContent()
         * @throws MWException If this test cases's needsDB() method doesn't return true.
         *         Test cases can use "@group Database" to enable database test support,
         *         or list the tables under testing in $this->tablesUsed, or override the
         *         needsDB() method.
         */
 -      protected function editPage( $pageName, $text, $summary = '', $defaultNs = NS_MAIN ) {
 +      protected function editPage(
 +              $pageName,
 +              $text,
 +              $summary = '',
 +              $defaultNs = NS_MAIN,
 +              User $user = null
 +      ) {
                if ( !$this->needsDB() ) {
                        throw new MWException( 'When testing which pages, the test cases\'s needsDB()' .
                                ' method should return true. Use @group Database or $this->tablesUsed.' );
                $title = Title::newFromText( $pageName, $defaultNs );
                $page = WikiPage::factory( $title );
  
 -              return $page->doEditContent( ContentHandler::makeContent( $text, $title ), $summary );
 +              return $page->doEditContent(
 +                      ContentHandler::makeContent( $text, $title ),
 +                      $summary,
 +                      0,
 +                      false,
 +                      $user
 +              );
        }
  
        /**