Merge "phpcs: Normalize methods declarations to "[final abstract] [visibility]"."
[lhc/web/wiklou.git] / tests / parser / parserTest.inc
index 6b56dcf..aa56e6e 100644 (file)
@@ -74,6 +74,7 @@ class ParserTest {
 
        public $regex = "";
        private $savedGlobals = array();
+
        /**
         * Sets terminal colorization and diff/quick modes depending on OS and
         * command-line options (--color and --quick).
@@ -83,14 +84,14 @@ class ParserTest {
                $this->color = !wfIsWindows() && Maintenance::posix_isatty( 1 );
 
                if ( isset( $options['color'] ) ) {
-                       switch( $options['color'] ) {
-                       case 'no':
-                               $this->color = false;
-                               break;
-                       case 'yes':
-                       default:
-                               $this->color = true;
-                               break;
+                       switch ( $options['color'] ) {
+                               case 'no':
+                                       $this->color = false;
+                                       break;
+                               case 'yes':
+                               default:
+                                       $this->color = true;
+                                       break;
                        }
                }
 
@@ -102,7 +103,7 @@ class ParserTest {
                $this->showProgress = !isset( $options['quiet'] );
                $this->showFailure = !(
                        isset( $options['quiet'] )
-                       && ( isset( $options['record'] )
+                               && ( isset( $options['record'] )
                                || isset( $options['compare'] ) ) ); // redundant output
 
                $this->showOutput = isset( $options['show-output'] );
@@ -152,26 +153,26 @@ class ParserTest {
                $wgExtensionAssetsPath = '/extensions';
                $wgThumbnailScriptPath = false;
                $wgLockManagers = array( array(
-                       'name'          => 'fsLockManager',
-                       'class'         => 'FSLockManager',
+                       'name' => 'fsLockManager',
+                       'class' => 'FSLockManager',
                        'lockDirectory' => wfTempDir() . '/test-repo/lockdir',
                ), array(
-                       'name'          => 'nullLockManager',
-                       'class'         => 'NullLockManager',
+                       'name' => 'nullLockManager',
+                       'class' => 'NullLockManager',
                ) );
                $wgLocalFileRepo = array(
-                       'class'           => 'LocalRepo',
-                       'name'            => 'local',
-                       'url'             => 'http://example.com/images',
-                       'hashLevels'      => 2,
+                       'class' => 'LocalRepo',
+                       'name' => 'local',
+                       'url' => 'http://example.com/images',
+                       'hashLevels' => 2,
                        'transformVia404' => false,
-                       'backend'         => new FSFileBackend( array(
-                               'name'        => 'local-backend',
+                       'backend' => new FSFileBackend( array(
+                               'name' => 'local-backend',
                                'lockManager' => 'fsLockManager',
                                'containerPaths' => array(
-                                       'local-public'  => wfTempDir() . '/test-repo/public',
-                                       'local-thumb'   => wfTempDir() . '/test-repo/thumb',
-                                       'local-temp'    => wfTempDir() . '/test-repo/temp',
+                                       'local-public' => wfTempDir() . '/test-repo/public',
+                                       'local-thumb' => wfTempDir() . '/test-repo/thumb',
+                                       'local-temp' => wfTempDir() . '/test-repo/temp',
                                        'local-deleted' => wfTempDir() . '/test-repo/deleted',
                                )
                        ) )
@@ -206,16 +207,16 @@ class ParserTest {
                $wgRequest = $context->getRequest();
 
                if ( $wgStyleDirectory === false ) {
-                       $wgStyleDirectory   = "$IP/skins";
+                       $wgStyleDirectory = "$IP/skins";
                }
 
        }
 
-       public function setupRecorder ( $options ) {
+       public function setupRecorder( $options ) {
                if ( isset( $options['record'] ) ) {
                        $this->recorder = new DbTestRecorder( $this );
                        $this->recorder->version = isset( $options['setversion'] ) ?
-                                       $options['setversion'] : SpecialVersion::getVersion();
+                               $options['setversion'] : SpecialVersion::getVersion();
                } elseif ( isset( $options['compare'] ) ) {
                        $this->recorder = new DbTestPreviewer( $this );
                } else {
@@ -230,8 +231,7 @@ class ParserTest {
        public static function chomp( $s ) {
                if ( substr( $s, -1 ) === "\n" ) {
                        return substr( $s, 0, -1 );
-               }
-               else {
+               } else {
                        return $s;
                }
        }
@@ -390,7 +390,7 @@ class ParserTest {
 
                        $this->teardownDatabase();
                        $this->recorder->report();
-               } catch (DBError $e) {
+               } catch ( DBError $e ) {
                        echo $e->getMessage();
                }
                $this->recorder->end();
@@ -463,8 +463,7 @@ class ParserTest {
 
                if ( isset( $opts['title'] ) ) {
                        $titleText = $opts['title'];
-               }
-               else {
+               } else {
                        $titleText = 'Parser test';
                }
 
@@ -638,12 +637,12 @@ class ParserTest {
                        'wgArticlePath' => '/wiki/$1',
                        'wgActionPaths' => array(),
                        'wgLockManagers' => array( array(
-                               'name'          => 'fsLockManager',
-                               'class'         => 'FSLockManager',
+                               'name' => 'fsLockManager',
+                               'class' => 'FSLockManager',
                                'lockDirectory' => $this->uploadDir . '/lockdir',
                        ), array(
-                               'name'          => 'nullLockManager',
-                               'class'         => 'NullLockManager',
+                               'name' => 'nullLockManager',
+                               'class' => 'NullLockManager',
                        ) ),
                        'wgLocalFileRepo' => array(
                                'class' => 'LocalRepo',
@@ -651,13 +650,13 @@ class ParserTest {
                                'url' => 'http://example.com/images',
                                'hashLevels' => 2,
                                'transformVia404' => false,
-                               'backend'         => new FSFileBackend( array(
-                                       'name'        => 'local-backend',
+                               'backend' => new FSFileBackend( array(
+                                       'name' => 'local-backend',
                                        'lockManager' => 'fsLockManager',
                                        'containerPaths' => array(
-                                               'local-public'  => $this->uploadDir,
-                                               'local-thumb'   => $this->uploadDir . '/thumb',
-                                               'local-temp'    => $this->uploadDir . '/temp',
+                                               'local-public' => $this->uploadDir,
+                                               'local-thumb' => $this->uploadDir . '/thumb',
+                                               'local-temp' => $this->uploadDir . '/temp',
                                                'local-deleted' => $this->uploadDir . '/delete',
                                        )
                                ) )
@@ -685,10 +684,10 @@ class ParserTest {
                        'wgVariantArticlePath' => false,
                        'wgGroupPermissions' => array( '*' => array(
                                'createaccount' => true,
-                               'read'          => true,
-                               'edit'          => true,
-                               'createpage'    => true,
-                               'createtalk'    => true,
+                               'read' => true,
+                               'edit' => true,
+                               'createpage' => true,
+                               'createtalk' => true,
                        ) ),
                        'wgNamespaceProtection' => array( NS_MEDIAWIKI => 'editinterface' ),
                        'wgDefaultExternalStore' => array(),
@@ -755,7 +754,7 @@ class ParserTest {
                $tables = array( 'user', 'user_properties', 'user_former_groups', 'page', 'page_restrictions',
                        'protected_titles', 'revision', 'text', 'pagelinks', 'imagelinks',
                        'categorylinks', 'templatelinks', 'externallinks', 'langlinks', 'iwlinks',
-                       'site_stats', 'hitcounter',     'ipblocks', 'image', 'oldimage',
+                       'site_stats', 'hitcounter', 'ipblocks', 'image', 'oldimage',
                        'recentchanges', 'watchlist', 'interwiki', 'logging',
                        'querycache', 'objectcache', 'job', 'l10n_cache', 'redirect', 'querycachetwo',
                        'archive', 'user_groups', 'page_props', 'category', 'msg_resource', 'msg_resource_links'
@@ -818,44 +817,44 @@ class ParserTest {
 
                        # Anonymous user
                        $this->db->insert( 'user', array(
-                               'user_id'         => 0,
-                               'user_name'       => 'Anonymous' ) );
+                               'user_id' => 0,
+                               'user_name' => 'Anonymous' ) );
                }
 
                # Hack: insert a few Wikipedia in-project interwiki prefixes,
                # for testing inter-language links
                $this->db->insert( 'interwiki', array(
                        array( 'iw_prefix' => 'wikipedia',
-                                  'iw_url'    => 'http://en.wikipedia.org/wiki/$1',
-                                  'iw_api'    => '',
-                                  'iw_wikiid' => '',
-                                  'iw_local'  => 0 ),
+                               'iw_url' => 'http://en.wikipedia.org/wiki/$1',
+                               'iw_api' => '',
+                               'iw_wikiid' => '',
+                               'iw_local' => 0 ),
                        array( 'iw_prefix' => 'meatball',
-                                  'iw_url'    => 'http://www.usemod.com/cgi-bin/mb.pl?$1',
-                                  'iw_api'    => '',
-                                  'iw_wikiid' => '',
-                                  'iw_local'  => 0 ),
+                               'iw_url' => 'http://www.usemod.com/cgi-bin/mb.pl?$1',
+                               'iw_api' => '',
+                               'iw_wikiid' => '',
+                               'iw_local' => 0 ),
                        array( 'iw_prefix' => 'zh',
-                                  'iw_url'    => 'http://zh.wikipedia.org/wiki/$1',
-                                  'iw_api'    => '',
-                                  'iw_wikiid' => '',
-                                  'iw_local'  => 1 ),
+                               'iw_url' => 'http://zh.wikipedia.org/wiki/$1',
+                               'iw_api' => '',
+                               'iw_wikiid' => '',
+                               'iw_local' => 1 ),
                        array( 'iw_prefix' => 'es',
-                                  'iw_url'    => 'http://es.wikipedia.org/wiki/$1',
-                                  'iw_api'    => '',
-                                  'iw_wikiid' => '',
-                                  'iw_local'  => 1 ),
+                               'iw_url' => 'http://es.wikipedia.org/wiki/$1',
+                               'iw_api' => '',
+                               'iw_wikiid' => '',
+                               'iw_local' => 1 ),
                        array( 'iw_prefix' => 'fr',
-                                  'iw_url'    => 'http://fr.wikipedia.org/wiki/$1',
-                                  'iw_api'    => '',
-                                  'iw_wikiid' => '',
-                                  'iw_local'  => 1 ),
+                               'iw_url' => 'http://fr.wikipedia.org/wiki/$1',
+                               'iw_api' => '',
+                               'iw_wikiid' => '',
+                               'iw_local' => 1 ),
                        array( 'iw_prefix' => 'ru',
-                                  'iw_url'    => 'http://ru.wikipedia.org/wiki/$1',
-                                  'iw_api'    => '',
-                                  'iw_wikiid' => '',
-                                  'iw_local'  => 1 ),
-                       ) );
+                               'iw_url' => 'http://ru.wikipedia.org/wiki/$1',
+                               'iw_api' => '',
+                               'iw_wikiid' => '',
+                               'iw_local' => 1 ),
+               ) );
 
                # Update certain things in site_stats
                $this->db->insert( 'site_stats', array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ) );
@@ -870,30 +869,30 @@ 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'        => wfBaseConvert( '', 16, 36, 31 ),
-                       'fileExists'  => true
-                       ), $this->db->timestamp( '20010115123500' ), $user );
+                       'size' => 12345,
+                       'width' => 1941,
+                       'height' => 220,
+                       'bits' => 24,
+                       'media_type' => MEDIATYPE_BITMAP,
+                       'mime' => 'image/jpeg',
+                       'metadata' => serialize( array() ),
+                       'sha1' => wfBaseConvert( '', 16, 36, 31 ),
+                       'fileExists' => true
+               ), $this->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'        => wfBaseConvert( '', 16, 36, 31 ),
-                       'fileExists'  => true
-                       ), $this->db->timestamp( '20010115123500' ), $user );
+                       'size' => 12345,
+                       'width' => 320,
+                       'height' => 240,
+                       'bits' => 24,
+                       'media_type' => MEDIATYPE_BITMAP,
+                       'mime' => 'image/jpeg',
+                       'metadata' => serialize( array() ),
+                       'sha1' => wfBaseConvert( '', 16, 36, 31 ),
+                       'fileExists' => true
+               ), $this->db->timestamp( '20010115123500' ), $user );
        }
 
        public function teardownDatabase() {
@@ -907,7 +906,7 @@ class ParserTest {
                $this->databaseSetupDone = false;
 
                if ( $this->useTemporaryTables ) {
-                       if( $this->db->getType() == 'sqlite' ) {
+                       if ( $this->db->getType() == 'sqlite' ) {
                                # Under SQLite the searchindex table is virtual and need
                                # to be explicitly destroyed. See bug 29912
                                # See also MediaWikiTestCase::destroyDB()
@@ -926,8 +925,9 @@ class ParserTest {
                        $this->db->query( $sql );
                }
 
-               if ( $this->db->getType() == 'oracle' )
+               if ( $this->db->getType() == 'oracle' ) {
                        $this->db->query( 'BEGIN FILL_WIKI_INFO; END;' );
+               }
 
                $this->teardownGlobals();
        }
@@ -990,7 +990,7 @@ class ParserTest {
 
                // delete the files first, then the dirs.
                self::deleteFiles(
-                       array (
+                       array(
                                "$dir/3/3a/Foobar.jpg",
                                "$dir/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg",
                                "$dir/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg",
@@ -1014,7 +1014,7 @@ class ParserTest {
                );
 
                self::deleteDirs(
-                       array (
+                       array(
                                "$dir/3/3a",
                                "$dir/3",
                                "$dir/thumb/6/65",
@@ -1135,8 +1135,8 @@ class ParserTest {
                $outfile = "$prefix-$outFileTail";
                $this->dumpToFile( $output, $outfile );
 
-               $shellInfile = wfEscapeShellArg($infile);
-               $shellOutfile = wfEscapeShellArg($outfile);
+               $shellInfile = wfEscapeShellArg( $infile );
+               $shellOutfile = wfEscapeShellArg( $outfile );
 
                global $wgDiff3;
                // we assume that people with diff3 also have usual diff
@@ -1172,7 +1172,7 @@ class ParserTest {
                return preg_replace(
                        array( '/^(-.*)$/m', '/^(\+.*)$/m' ),
                        array( $this->term->color( 34 ) . '$1' . $this->term->reset(),
-                                  $this->term->color( 31 ) . '$1' . $this->term->reset() ),
+                               $this->term->color( 31 ) . '$1' . $this->term->reset() ),
                        $text );
        }
 
@@ -1237,7 +1237,7 @@ class ParserTest {
        public function requireHook( $name ) {
                global $wgParser;
 
-               $wgParser->firstCallInit( ); // make sure hooks are loaded.
+               $wgParser->firstCallInit(); // make sure hooks are loaded.
 
                if ( isset( $wgParser->mTagHooks[$name] ) ) {
                        $this->hooks[$name] = $wgParser->mTagHooks[$name];
@@ -1260,7 +1260,7 @@ class ParserTest {
        public function requireFunctionHook( $name ) {
                global $wgParser;
 
-               $wgParser->firstCallInit( ); // make sure hooks are loaded.
+               $wgParser->firstCallInit(); // make sure hooks are loaded.
 
                if ( isset( $wgParser->mFunctionHooks[$name] ) ) {
                        $this->functionHooks[$name] = $wgParser->mFunctionHooks[$name];
@@ -1292,9 +1292,9 @@ class ParserTest {
        private function wellFormed( $text ) {
                $html =
                        Sanitizer::hackDocType() .
-                       '<html>' .
-                       $text .
-                       '</html>';
+                               '<html>' .
+                               $text .
+                               '</html>';
 
                $parser = xml_parser_create( "UTF-8" );