Merge "Make TOC hideable"
[lhc/web/wiklou.git] / tests / phpunit / includes / parser / NewParserTest.php
index 9551b2f..eac4de5 100644 (file)
@@ -6,6 +6,8 @@
  * @group Database
  * @group Parser
  * @group Stub
+ *
+ * @todo covers tags
  */
 class NewParserTest extends MediaWikiTestCase {
        static protected $articles = array(); // Array of test articles defined by the tests
@@ -37,7 +39,7 @@ class NewParserTest extends MediaWikiTestCase {
        }
 
        protected function setUp() {
-               global $wgNamespaceAliases;
+               global $wgNamespaceAliases, $wgContLang;
                global $wgHooks, $IP;
 
                parent::setUp();
@@ -105,11 +107,14 @@ class NewParserTest extends MediaWikiTestCase {
                ) );
                $tmpGlobals['wgNamespaceProtection'] = array( NS_MEDIAWIKI => 'editinterface' );
 
-               $tmpGlobals['wgParser'] = new StubObject( 'wgParser', $GLOBALS['wgParserConf']['class'], array( $GLOBALS['wgParserConf'] ) );
+               $tmpGlobals['wgParser'] = new StubObject(
+                       'wgParser', $GLOBALS['wgParserConf']['class'],
+                       array( $GLOBALS['wgParserConf'] ) );
 
                $tmpGlobals['wgFileExtensions'][] = 'svg';
                $tmpGlobals['wgSVGConverter'] = 'rsvg';
-               $tmpGlobals['wgSVGConverters']['rsvg'] = '$path/rsvg-convert -w $width -h $height $input -o $output';
+               $tmpGlobals['wgSVGConverters']['rsvg'] =
+                       '$path/rsvg-convert -w $width -h $height $input -o $output';
 
                if ( $GLOBALS['wgStyleDirectory'] === false ) {
                        $tmpGlobals['wgStyleDirectory'] = "$IP/skins";
@@ -129,6 +134,9 @@ class NewParserTest extends MediaWikiTestCase {
                $tmpHooks['ParserTestParser'][] = 'ParserTestParserHook::setup';
                $tmpHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
                $tmpGlobals['wgHooks'] = $tmpHooks;
+               # add a namespace shadowing a interwiki link, to test
+               # proper precedence when resolving links. (bug 51680)
+               $tmpGlobals['wgExtraNamespaces'] = array( 100 => 'MemoryAlpha' );
 
                $this->setMwGlobals( $tmpGlobals );
 
@@ -137,10 +145,13 @@ class NewParserTest extends MediaWikiTestCase {
 
                $wgNamespaceAliases['Image'] = NS_FILE;
                $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
+
+               MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
+               $wgContLang->resetNamespaces(); # reset namespace cache
        }
 
        protected function tearDown() {
-               global $wgNamespaceAliases;
+               global $wgNamespaceAliases, $wgContLang;
 
                $wgNamespaceAliases['Image'] = $this->savedWeirdGlobals['image_alias'];
                $wgNamespaceAliases['Image_talk'] = $this->savedWeirdGlobals['image_talk_alias'];
@@ -156,6 +167,14 @@ class NewParserTest extends MediaWikiTestCase {
                MessageCache::destroyInstance();
 
                parent::tearDown();
+
+               MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
+               $wgContLang->resetNamespaces(); # reset namespace cache
+       }
+
+       public static function tearDownAfterClass() {
+               ParserTest::tearDownInterwikis();
+               parent::tearDownAfterClass();
        }
 
        function addDBData() {
@@ -612,6 +631,7 @@ class NewParserTest extends MediaWikiTestCase {
                        $out = $parser->getPreloadText( $input, $title, $options );
                } else {
                        $output = $parser->parse( $input, $title, $options, true, true, 1337 );
+                       $output->setTOCEnabled( !isset( $opts['notoc'] ) );
                        $out = $output->getText();
 
                        if ( isset( $opts['showtitle'] ) ) {
@@ -653,7 +673,7 @@ class NewParserTest extends MediaWikiTestCase {
         *
         * @group ParserFuzz
         */
-       function testFuzzTests() {
+       public function testFuzzTests() {
                global $wgParserTestFiles;
 
                $files = $wgParserTestFiles;
@@ -698,7 +718,9 @@ class NewParserTest extends MediaWikiTestCase {
                        } catch ( Exception $exception ) {
                                $input_dump = sprintf( "string(%d) \"%s\"\n", strlen( $input ), $input );
 
-                               $this->assertTrue( false, "Test $id, fuzz seed {$this->fuzzSeed}. \n\nInput: $input_dump\n\nError: {$exception->getMessage()}\n\nBacktrace: {$exception->getTraceAsString()}" );
+                               $this->assertTrue( false, "Test $id, fuzz seed {$this->fuzzSeed}. \n\n" .
+                                       "Input: $input_dump\n\nError: {$exception->getMessage()}\n\n" .
+                                       "Backtrace: {$exception->getTraceAsString()}" );
                        }
 
                        $this->teardownGlobals();