ParserTests: Make sure WikiPage::doEditContent() succeeds
authorKunal Mehta <legoktm@member.fsf.org>
Wed, 14 Sep 2016 00:22:44 +0000 (17:22 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Wed, 14 Sep 2016 00:22:44 +0000 (17:22 -0700)
If a parser test tries to create a page with invalid content (rejected
by Content::prepareSave() or Content::isValid()), throw an exception
instead of silently failing.

Change-Id: I89642604216699f27884120b3c297a0b277c47a6

tests/parser/ParserTestRunner.php

index 6659ff8..4ef778d 100644 (file)
@@ -1517,7 +1517,10 @@ class ParserTestRunner {
                        throw new MWException( "duplicate article '$name' at $file:$line\n" );
                }
 
-               $page->doEditContent( ContentHandler::makeContent( $text, $title ), '', EDIT_NEW );
+               $status = $page->doEditContent( ContentHandler::makeContent( $text, $title ), '', EDIT_NEW );
+               if ( !$status->isOK() ) {
+                       throw new MWException( $status->getWikiText( false, false, 'en' ) );
+               }
 
                // The RepoGroup cache is invalidated by the creation of file redirects
                if ( $title->getNamespace() === NS_IMAGE ) {