From: Umherirrender Date: Sat, 16 Sep 2017 12:34:15 +0000 (+0200) Subject: Allow duplicate articles in parser tests with same content X-Git-Tag: 1.31.0-rc.0~1867^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=cc83ccf6c4f4499d2689f88c6e9b9400988aa597;hp=-c Allow duplicate articles in parser tests with same content Some extensions needs Template:(( in the parser tests, but when using phpunit tests all pages are created at the begin, which gives errors like 'duplicate article 'Template:((' at /Arrays/arrayLoopsInteractionParserTests.txt:10 Change-Id: Iefa3dc8d647d58f2d5382b847bbd6228f46faff3 --- cc83ccf6c4f4499d2689f88c6e9b9400988aa597 diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 0121d53e63..149ba800f2 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -1592,11 +1592,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 +1616,7 @@ class ParserTestRunner { $restore = $this->executeSetupSnippets( [ 'wgParser' => new ParserTestMockParser ] ); try { $status = $page->doEditContent( - ContentHandler::makeContent( $text, $title ), + $newContent, '', EDIT_NEW | EDIT_INTERNAL );