Merge "Change "e-mail" to "email" in Log-action-filter-newusers-byemail/en"
[lhc/web/wiklou.git] / tests / parser / ParserTestRunner.php
index bc5f1fc..3eb25a9 100644 (file)
@@ -75,11 +75,6 @@ class ParserTestRunner {
         */
        private $dbClone;
 
-       /**
-        * @var TidySupport
-        */
-       private $tidySupport;
-
        /**
         * @var TidyDriverBase
         */
@@ -167,12 +162,6 @@ class ParserTestRunner {
 
                $this->disableSaveParse = !empty( $options['disable-save-parse'] );
 
-               $this->tidySupport = new TidySupport( !empty( $options['use-tidy-config'] ) );
-               if ( !$this->tidySupport->isEnabled() ) {
-                       $this->recorder->warning(
-                               "Warning: tidy is not installed, skipping some tests\n" );
-               }
-
                if ( isset( $options['upload-dir'] ) ) {
                        $this->uploadDir = $options['upload-dir'];
                }
@@ -293,7 +282,6 @@ class ParserTestRunner {
                $setup['wgHtml5'] = true;
                $setup['wgDisableLangConversion'] = false;
                $setup['wgDisableTitleConversion'] = false;
-               $setup['wgMediaInTargetLanguage'] = false;
 
                // "extra language links"
                // see https://gerrit.wikimedia.org/r/111390
@@ -400,10 +388,10 @@ class ParserTestRunner {
                        100 => 'MemoryAlpha',
                        101 => 'MemoryAlpha_talk'
                ];
-               // Changing wgExtraNamespaces invalidates caches in MWNamespace and
-               // any live Language object, both on setup and teardown
+               // Changing wgExtraNamespaces invalidates caches in NamespaceInfo and any live Language
+               // object, both on setup and teardown
                $reset = function () {
-                       MWNamespace::clearCaches();
+                       MediaWikiServices::getInstance()->resetServiceForTesting( 'NamespaceInfo' );
                        MediaWikiServices::getInstance()->getContentLanguage()->resetNamespaces();
                };
                $setup[] = $reset;
@@ -833,12 +821,7 @@ class ParserTestRunner {
                $options->setTimestamp( $this->getFakeTimestamp() );
 
                if ( isset( $opts['tidy'] ) ) {
-                       if ( !$this->tidySupport->isEnabled() ) {
-                               $this->recorder->skipped( $test, 'tidy extension is not installed' );
-                               return false;
-                       } else {
-                               $options->setTidy( true );
-                       }
+                       $options->setTidy( true );
                }
 
                if ( isset( $opts['title'] ) ) {
@@ -955,12 +938,7 @@ class ParserTestRunner {
         */
        private static function getOptionValue( $key, $opts, $default ) {
                $key = strtolower( $key );
-
-               if ( isset( $opts[$key] ) ) {
-                       return $opts[$key];
-               } else {
-                       return $default;
-               }
+               return $opts[$key] ?? $default;
        }
 
        /**
@@ -1106,7 +1084,6 @@ class ParserTestRunner {
                                + [ 'ISBN' => true, 'PMID' => true, 'RFC' => true ],
                        // Test with legacy encoding by default until HTML5 is very stable and default
                        'wgFragmentMode' => [ 'legacy' ],
-                       'wgMediaInTargetLanguage' => self::getOptionValue( 'wgMediaInTargetLanguage', $opts, false ),
                ];
 
                $nonIncludable = self::getOptionValue( 'wgNonincludableNamespaces', $opts, false );
@@ -1130,7 +1107,7 @@ class ParserTestRunner {
                if ( isset( $opts['tidy'] ) ) {
                        // Cache a driver instance
                        if ( $this->tidyDriver === null ) {
-                               $this->tidyDriver = MWTidy::factory( $this->tidySupport->getConfig() );
+                               $this->tidyDriver = MWTidy::factory();
                        }
                        $tidy = $this->tidyDriver;
                } else {
@@ -1140,6 +1117,7 @@ class ParserTestRunner {
                # Suppress warnings about running tests without tidy
                Wikimedia\suppressWarnings();
                wfDeprecated( 'disabling tidy' );
+               wfDeprecated( 'MWTidy::setInstance' );
                Wikimedia\restoreWarnings();
 
                MWTidy::setInstance( $tidy );
@@ -1214,7 +1192,7 @@ class ParserTestRunner {
         * @return array
         */
        private function listTables() {
-               global $wgCommentTableSchemaMigrationStage, $wgActorTableSchemaMigrationStage;
+               global $wgActorTableSchemaMigrationStage;
 
                $tables = [ 'user', 'user_properties', 'user_former_groups', 'page', 'page_restrictions',
                        'protected_titles', 'revision', 'ip_changes', 'text', 'pagelinks', 'imagelinks',
@@ -1224,14 +1202,9 @@ class ParserTestRunner {
                        'querycache', 'objectcache', 'job', 'l10n_cache', 'redirect', 'querycachetwo',
                        'archive', 'user_groups', 'page_props', 'category',
                        'slots', 'content', 'slot_roles', 'content_models',
+                       'comment', 'revision_comment_temp',
                ];
 
-               if ( $wgCommentTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) {
-                       // The new tables for comments are in use
-                       $tables[] = 'comment';
-                       $tables[] = 'revision_comment_temp';
-               }
-
                if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
                        // The new tables for actors are in use
                        $tables[] = 'actor';
@@ -1746,10 +1719,10 @@ class ParserTestRunner {
         * @return bool True if tag hook is present
         */
        public function requireHook( $name ) {
-               global $wgParser;
+               $parser = MediaWikiServices::getInstance()->getParser();
 
-               $wgParser->firstCallInit(); // make sure hooks are loaded.
-               if ( isset( $wgParser->mTagHooks[$name] ) ) {
+               $parser->firstCallInit(); // make sure hooks are loaded.
+               if ( isset( $parser->mTagHooks[$name] ) ) {
                        return true;
                } else {
                        $this->recorder->warning( "   This test suite requires the '$name' hook " .
@@ -1765,11 +1738,11 @@ class ParserTestRunner {
         * @return bool True if function hook is present
         */
        public function requireFunctionHook( $name ) {
-               global $wgParser;
+               $parser = MediaWikiServices::getInstance()->getParser();
 
-               $wgParser->firstCallInit(); // make sure hooks are loaded.
+               $parser->firstCallInit(); // make sure hooks are loaded.
 
-               if ( isset( $wgParser->mFunctionHooks[$name] ) ) {
+               if ( isset( $parser->mFunctionHooks[$name] ) ) {
                        return true;
                } else {
                        $this->recorder->warning( "   This test suite requires the '$name' function " .
@@ -1785,11 +1758,11 @@ class ParserTestRunner {
         * @return bool True if function hook is present
         */
        public function requireTransparentHook( $name ) {
-               global $wgParser;
+               $parser = MediaWikiServices::getInstance()->getParser();
 
-               $wgParser->firstCallInit(); // make sure hooks are loaded.
+               $parser->firstCallInit(); // make sure hooks are loaded.
 
-               if ( isset( $wgParser->mTransparentTagHooks[$name] ) ) {
+               if ( isset( $parser->mTransparentTagHooks[$name] ) ) {
                        return true;
                } else {
                        $this->recorder->warning( "   This test suite requires the '$name' transparent " .