Use ParserOutput stateless transforms
[lhc/web/wiklou.git] / tests / parser / ParserTestRunner.php
index 0121d53..44a00a8 100644 (file)
@@ -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
                        );