tests: Reset LanguageConverter conversion tables between test cases
authorC. Scott Ananian <cscott@cscott.net>
Mon, 26 Jun 2017 17:56:30 +0000 (13:56 -0400)
committerC. Scott Ananian <cscott@cscott.net>
Mon, 26 Jun 2017 17:56:30 +0000 (13:56 -0400)
Conversion rules defined in a previous test case were leaking into
subsequent test cases.  Existing tests had worked around this by defining
non-overlapping rules, but it's better to just fix the problem at the
source.

Change-Id: I65736520cd04bfe8949b29ade07338a6e1b88a4d

languages/FakeConverter.php
languages/LanguageConverter.php
tests/parser/ParserTestRunner.php

index 0cddc99..0bf88c6 100644 (file)
@@ -125,4 +125,7 @@ class FakeConverter {
 
        public function updateConversionTable( Title $title ) {
        }
+
+       public function reloadTables() {
+       }
 }
index 19d644c..ef88c12 100644 (file)
@@ -891,7 +891,9 @@ class LanguageConverter {
        /**
         * Reload the conversion tables.
         *
-        * @private
+        * Public only for use by test suites which need to reset the converter
+        * state.
+        *
         */
        function reloadTables() {
                if ( $this->mTables ) {
index f44b0d5..26c5586 100644 (file)
@@ -1045,6 +1045,8 @@ class ParserTestRunner {
                $context->setUser( $user );
                $context->setLanguage( $lang );
                $teardown[] = function () use ( $context ) {
+                       // Clear language conversion tables
+                       $context->getLanguage()->getConverter()->reloadTables();
                        // Reset context to the restored globals
                        $context->setUser( $GLOBALS['wgUser'] );
                        $context->setLanguage( $GLOBALS['wgContLang'] );