Merge "tests: Use TestingAccessWrapper to reload LanguageConverter tables"
[lhc/web/wiklou.git] / tests / parser / ParserTestRunner.php
index 7edde2a..a373142 100644 (file)
  * @file
  * @ingroup Testing
  */
+use Wikimedia\Rdbms\IDatabase;
 use MediaWiki\MediaWikiServices;
 use Wikimedia\ScopedCallback;
+use Wikimedia\TestingAccessWrapper;
 
 /**
  * @ingroup Testing
@@ -239,7 +241,7 @@ class ParserTestRunner {
                        'name' => 'nullLockManager',
                        'class' => 'NullLockManager',
                ] ];
-               $reset = function() {
+               $reset = function () {
                        LockManagerGroup::destroySingletons();
                };
                $setup[] = $reset;
@@ -287,7 +289,7 @@ class ParserTestRunner {
                MediaWikiServices::getInstance()->disableService( 'MediaHandlerFactory' );
                MediaWikiServices::getInstance()->redefineService(
                        'MediaHandlerFactory',
-                       function() {
+                       function () {
                                return new MockMediaHandlerFactory();
                        }
                );
@@ -427,7 +429,7 @@ class ParserTestRunner {
         * @return ScopedCallback
         */
        protected function createTeardownObject( $teardown, $nextTeardown = null ) {
-               return new ScopedCallback( function() use ( $teardown, $nextTeardown ) {
+               return new ScopedCallback( function () use ( $teardown, $nextTeardown ) {
                        // Schedule teardown snippets in reverse order
                        $teardown = array_reverse( $teardown );
 
@@ -746,6 +748,10 @@ class ParserTestRunner {
                $user = $context->getUser();
                $options = ParserOptions::newFromContext( $context );
 
+               if ( !isset( $opts['wrap'] ) ) {
+                       $options->setWrapOutputClass( false );
+               }
+
                if ( isset( $opts['tidy'] ) ) {
                        if ( !$this->tidySupport->isEnabled() ) {
                                $this->recorder->skipped( $test, 'tidy extension is not installed' );
@@ -974,10 +980,9 @@ class ParserTestRunner {
                        'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
                        'wgLanguageCode' => $langCode,
                        'wgRawHtml' => self::getOptionValue( 'wgRawHtml', $opts, false ),
-                       'wgNamespacesWithSubpages' => [
-                               0 => isset( $opts['subpage'] ),
-                               2 => isset( $opts['subpage'] ),
-                       ],
+                       'wgNamespacesWithSubpages' => array_fill_keys(
+                               MWNamespace::getValidNamespaces(), isset( $opts['subpage'] )
+                       ),
                        'wgMaxTocLevel' => $maxtoclevel,
                        'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ),
                        'wgThumbLimits' => [ self::getOptionValue( 'thumbsize', $opts, 180 ) ],
@@ -1041,6 +1046,11 @@ class ParserTestRunner {
                $context->setUser( $user );
                $context->setLanguage( $lang );
                $teardown[] = function () use ( $context ) {
+                       // Clear language conversion tables
+                       $wrapper = TestingAccessWrapper::newFromObject(
+                               $context->getLanguage()->getConverter()
+                       );
+                       $wrapper->reloadTables();
                        // Reset context to the restored globals
                        $context->setUser( $GLOBALS['wgUser'] );
                        $context->setLanguage( $GLOBALS['wgContLang'] );