X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fparser%2FParserTestRunner.php;h=44a00a8964e2156eda7223959b512b980a3058a4;hp=5fe2177d11328851ab745f2cff4be2a448fc75c5;hb=e74ba29aa6b86995a79200fc8b1bb2932d3a1675;hpb=03cd9495a4dac1c1cda738d52e74b553b977beb8 diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 5fe2177d11..44a00a8964 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -384,7 +384,7 @@ class ParserTestRunner { // Changing wgExtraNamespaces invalidates caches in MWNamespace and // any live Language object, both on setup and teardown $reset = function () { - MWNamespace::getCanonicalNamespaces( true ); + MWNamespace::clearCaches(); $GLOBALS['wgContLang']->resetNamespaces(); }; $setup[] = $reset; @@ -853,8 +853,9 @@ class ParserTestRunner { $out = $parser->getPreloadText( $test['input'], $title, $options ); } else { $output = $parser->parse( $test['input'], $title, $options, true, true, 1337 ); - $output->setTOCEnabled( !isset( $opts['notoc'] ) ); - $out = $output->getText(); + $out = $output->getText( [ + 'allowTOC' => !isset( $opts['notoc'] ) + ] ); if ( isset( $opts['tidy'] ) ) { $out = preg_replace( '/\s+$/', '', $out ); } @@ -1592,11 +1593,21 @@ class ParserTestRunner { throw new MWException( "invalid title '$name' at $file:$line\n" ); } + $newContent = ContentHandler::makeContent( $text, $title ); + $page = WikiPage::factory( $title ); $page->loadPageData( 'fromdbmaster' ); if ( $page->exists() ) { - throw new MWException( "duplicate article '$name' at $file:$line\n" ); + $content = $page->getContent( Revision::RAW ); + // Only reject the title, if the content/content model is different. + // This makes it easier to create Template:(( or Template:)) in different extensions + if ( $newContent->equals( $content ) ) { + return; + } + throw new MWException( + "duplicate article '$name' with different content at $file:$line\n" + ); } // Use mock parser, to make debugging of actual parser tests simpler. @@ -1606,7 +1617,7 @@ class ParserTestRunner { $restore = $this->executeSetupSnippets( [ 'wgParser' => new ParserTestMockParser ] ); try { $status = $page->doEditContent( - ContentHandler::makeContent( $text, $title ), + $newContent, '', EDIT_NEW | EDIT_INTERNAL );