X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fparser%2FParserTestRunner.php;h=44a00a8964e2156eda7223959b512b980a3058a4;hb=d0142faf253e069473888dc378979b804fb2b07e;hp=46c551b68f424d2cbf75a46a5d66118e4d55ac03;hpb=f0bef2cf6994c49031d89425b3b3c56fd0e89a65;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 46c551b68f..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; @@ -518,6 +518,8 @@ class ParserTestRunner { /** * Ensure a given setup stage has been done, throw an exception if it has * not. + * @param string $funcName + * @param string|null $funcName2 */ protected function checkSetupDone( $funcName, $funcName2 = null ) { if ( !$this->setupDone[$funcName] @@ -700,6 +702,8 @@ class ParserTestRunner { /** * Determine whether the current parser has the hooks registered in it * that are required by a file read by TestFileReader. + * @param array $requirements + * @return bool */ public function meetsRequirements( $requirements ) { foreach ( $requirements as $requirement ) { @@ -849,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 ); } @@ -1588,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. @@ -1600,12 +1615,15 @@ class ParserTestRunner { // get a reference to the mock object. MessageCache::singleton()->getParser(); $restore = $this->executeSetupSnippets( [ 'wgParser' => new ParserTestMockParser ] ); - $status = $page->doEditContent( - ContentHandler::makeContent( $text, $title ), - '', - EDIT_NEW | EDIT_INTERNAL - ); - $restore(); + try { + $status = $page->doEditContent( + $newContent, + '', + EDIT_NEW | EDIT_INTERNAL + ); + } finally { + $restore(); + } if ( !$status->isOK() ) { throw new MWException( $status->getWikiText( false, false, 'en' ) );