w/s changes
[lhc/web/wiklou.git] / maintenance / parserTests.inc
index f574429..05327c1 100644 (file)
@@ -41,7 +41,7 @@ class ParserTest {
        /**
         * boolean $useTemporaryTables Use temporary tables for the temporary database
         */
-       private $useTemporaryTables = false;
+       private $useTemporaryTables = true;
 
        /**
         * boolean $databaseSetupDone True if the database has been set up
@@ -335,7 +335,6 @@ class ParserTest {
                $user = new User();
                $options = ParserOptions::newFromUser( $user );
 
-               $m = array();
                if ( isset( $opts['title'] ) ) {
                        $titleText = $opts['title'];
                }
@@ -349,7 +348,6 @@ class ParserTest {
                $parser = $this->getParser( $preprocessor );
                $title = Title::newFromText( $titleText );
 
-               $matches = array();
                if ( isset( $opts['pst'] ) ) {
                        $out = $parser->preSaveTransform( $input, $title, $user, $options );
                } elseif ( isset( $opts['msg'] ) ) {
@@ -596,16 +594,16 @@ class ParserTest {
         */
        private function listTables() {
                global $wgDBtype;
-               $tables = array( 'user', 'page', 'page_restrictions',
+               $tables = array( 'user', 'user_properties', 'page', 'page_restrictions',
                        'protected_titles', 'revision', 'text', 'pagelinks', 'imagelinks',
                        'categorylinks', 'templatelinks', 'externallinks', 'langlinks', 'iwlinks',
                        'site_stats', 'hitcounter',     'ipblocks', 'image', 'oldimage',
-                       'recentchanges', 'watchlist', 'math', 'interwiki',
+                       'recentchanges', 'watchlist', 'math', 'interwiki', 'logging',
                        'querycache', 'objectcache', 'job', 'l10n_cache', 'redirect', 'querycachetwo',
                        'archive', 'user_groups', 'page_props', 'category',
                );
 
-               if ( $wgDBtype === 'mysql' )
+               if ( in_array( $wgDBtype, array( 'mysql', 'sqlite' ) ) )
                        array_push( $tables, 'searchindex' );
 
                // Allow extensions to add to the list of tables to duplicate;
@@ -659,7 +657,7 @@ class ParserTest {
                                $db->query( "DROP TABLE IF EXISTS $newTableName" );
                        } elseif ( in_array( $wgDBtype, array( 'postgres', 'oracle' ) ) ) {
                                /* DROPs wouldn't work due to Foreign Key Constraints (bug 14990, r58669)
-                                * Use "DROP TABLE IF EXISTS $newTableName CASCADE" for postgres? That 
+                                * Use "DROP TABLE IF EXISTS $newTableName CASCADE" for postgres? That
                                 * syntax would also work for mysql.
                                 */
                        } elseif ( $db->tableExists( $tbl ) ) {
@@ -732,24 +730,28 @@ class ParserTest {
                $user = User::createNew( 'WikiSysop' );
                $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.jpg' ) );
                $image->recordUpload2( '', 'Upload of some lame file', 'Some lame file', array(
+                       'size'        => 12345,
                        'width'       => 1941,
                        'height'      => 220,
                        'bits'        => 24,
                        'media_type'  => MEDIATYPE_BITMAP,
                        'mime'        => 'image/jpeg',
                        'metadata'    => serialize( array() ),
+                       'sha1'        => sha1(''),
                        'fileExists'  => true
                        ), $db->timestamp( '20010115123500' ), $user );
 
                # This image will be blacklisted in [[MediaWiki:Bad image list]]
                $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Bad.jpg' ) );
                $image->recordUpload2( '', 'zomgnotcensored', 'Borderline image', array(
+                       'size'        => 12345,
                        'width'       => 320,
                        'height'      => 240,
                        'bits'        => 24,
                        'media_type'  => MEDIATYPE_BITMAP,
                        'mime'        => 'image/jpeg',
                        'metadata'    => serialize( array() ),
+                       'sha1'        => sha1(''),
                        'fileExists'  => true
                        ), $db->timestamp( '20010115123500' ), $user );
        }
@@ -1027,6 +1029,10 @@ class ParserTest {
         * @param $line Integer: the input line number, for reporting errors
         */
        public function addArticle( $name, $text, $line ) {
+               global $wgCapitalLinks;
+               $oldCapitalLinks = $wgCapitalLinks;
+               $wgCapitalLinks = true; // We only need this from SetupGlobals() See r70917#c8637
+
                $title = Title::newFromText( $name );
                if ( is_null( $title ) ) {
                        wfDie( "invalid title at line $line\n" );
@@ -1039,6 +1045,8 @@ class ParserTest {
 
                $art = new Article( $title );
                $art->insertNewArticle( $text, '', false, false );
+
+               $wgCapitalLinks = $oldCapitalLinks;
        }
 
        /**
@@ -1092,7 +1100,7 @@ class ParserTest {
        private function tidy( $text ) {
                global $wgUseTidy;
                if ( $wgUseTidy ) {
-                       $text = Parser::tidy( $text );
+                       $text = MWTidy::tidy( $text );
                }
                return $text;
        }
@@ -1344,22 +1352,22 @@ class DbTestPreviewer extends TestRecorder  {
        }
 
        /**
-        ** Returns a string giving information about when a test last had a status change.
-        ** Could help to track down when regressions were introduced, as distinct from tests
-        ** which have never passed (which are more change requests than regressions).
+        * Returns a string giving information about when a test last had a status change.
+        * Could help to track down when regressions were introduced, as distinct from tests
+        * which have never passed (which are more change requests than regressions).
         */
        private function getTestStatusInfo( $testname, $after ) {
 
                // If we're looking at a test that has just been removed, then say when it first appeared.
                if ( $after == 'n' ) {
                        $changedRun = $this->db->selectField ( 'testitem',
-                                                                                                  'MIN(ti_run)',
-                                                                                                  array( 'ti_name' => $testname ),
-                                                                                                  __METHOD__ );
+                               'MIN(ti_run)',
+                               array( 'ti_name' => $testname ),
+                               __METHOD__ );
                        $appear = $this->db->selectRow ( 'testrun',
-                                                                                        array( 'tr_date', 'tr_mw_version' ),
-                                                                                        array( 'tr_id' => $changedRun ),
-                                                                                        __METHOD__ );
+                               array( 'tr_date', 'tr_mw_version' ),
+                               array( 'tr_id' => $changedRun ),
+                               __METHOD__ );
                        return "First recorded appearance: "
                                   . date( "d-M-Y H:i:s",  strtotime ( $appear->tr_date ) )
                                   .  ", " . $appear->tr_mw_version;
@@ -1389,15 +1397,15 @@ class DbTestPreviewer extends TestRecorder  {
                // (i.e. it used to work, but now doesn't; or used to fail, but is now fixed.)
                // In this situation, give as much info as we can as to when it changed status.
                $pre  = $this->db->selectRow ( 'testrun',
-                                                                               array( 'tr_date', 'tr_mw_version' ),
-                                                                               array( 'tr_id' => $changedRun ),
-                                                                               __METHOD__ );
+                       array( 'tr_date', 'tr_mw_version' ),
+                       array( 'tr_id' => $changedRun ),
+                       __METHOD__ );
                $post = $this->db->selectRow ( 'testrun',
-                                                                               array( 'tr_date', 'tr_mw_version' ),
-                                                                               array( "tr_id > " . $this->db->addQuotes ( $changedRun ) ),
-                                                                               __METHOD__,
-                                                                               array( "LIMIT" => 1, "ORDER BY" => 'tr_id' )
-                                                                        );
+                       array( 'tr_date', 'tr_mw_version' ),
+                       array( "tr_id > " . $this->db->addQuotes ( $changedRun ) ),
+                       __METHOD__,
+                       array( "LIMIT" => 1, "ORDER BY" => 'tr_id' )
+               );
 
                if ( $post ) {
                        $postDate = date( "d-M-Y H:i:s",  strtotime ( $post->tr_date  ) ) . ", {$post->tr_mw_version}";