From: jenkins-bot Date: Tue, 15 Nov 2016 22:47:23 +0000 (+0000) Subject: Merge "parserTests: Use a mock parser during article insertion" X-Git-Tag: 1.31.0-rc.0~4857 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=37751ee23e7b7019307eafe36f18c8450bf2e420;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "parserTests: Use a mock parser during article insertion" --- 37751ee23e7b7019307eafe36f18c8450bf2e420 diff --combined tests/common/TestsAutoLoader.php index 0bfa318081,d79fbd77a1..66df315e10 --- a/tests/common/TestsAutoLoader.php +++ b/tests/common/TestsAutoLoader.php @@@ -35,13 -35,13 +35,14 @@@ $wgAutoloadClasses += 'DjVuSupport' => "$testDir/parser/DjVuSupport.php", 'TestRecorder' => "$testDir/parser/TestRecorder.php", 'MultiTestRecorder' => "$testDir/parser/MultiTestRecorder.php", + 'ParserTestMockParser' => "$testDir/parser/ParserTestMockParser.php", 'ParserTestRunner' => "$testDir/parser/ParserTestRunner.php", 'ParserTestParserHook' => "$testDir/parser/ParserTestParserHook.php", 'ParserTestPrinter' => "$testDir/parser/ParserTestPrinter.php", 'ParserTestResult' => "$testDir/parser/ParserTestResult.php", 'ParserTestResultNormalizer' => "$testDir/parser/ParserTestResultNormalizer.php", 'PhpunitTestRecorder' => "$testDir/parser/PhpunitTestRecorder.php", + 'TestFileEditor' => "$testDir/parser/TestFileEditor.php", 'TestFileReader' => "$testDir/parser/TestFileReader.php", 'TestRecorder' => "$testDir/parser/TestRecorder.php", 'TidySupport' => "$testDir/parser/TidySupport.php", diff --combined tests/parser/ParserTestRunner.php index e433c2ed9a,32b41ec9c5..04c142ab77 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@@ -26,7 -26,6 +26,7 @@@ * @ingroup Testing */ use MediaWiki\MediaWikiServices; +use Wikimedia\ScopedCallback; /** * @ingroup Testing @@@ -176,7 -175,7 +176,7 @@@ class ParserTestRunner // arrays: $setup and $teardown. The code snippets in the $setup array // are executed at the end of the method, before it returns, and the // code snippets in the $teardown array are executed in reverse order - // when the ScopedCallback object is consumed. + // when the Wikimedia\ScopedCallback object is consumed. // Because it is a common operation to save, set and restore global // variables, we have an additional convention: when the array key of @@@ -426,7 -425,7 +426,7 @@@ * @param ScopedCallback|null A ScopedCallback to consume * @return ScopedCallback */ - protected function createTeardownObject( $teardown, $nextTeardown ) { + protected function createTeardownObject( $teardown, $nextTeardown = null ) { return new ScopedCallback( function() use ( $teardown, $nextTeardown ) { // Schedule teardown snippets in reverse order $teardown = array_reverse( $teardown ); @@@ -1503,7 -1502,14 +1503,14 @@@ throw new MWException( "duplicate article '$name' at $file:$line\n" ); } + // Use mock parser, to make debugging of actual parser tests simpler. + // But initialise the MessageCache clone first, don't let MessageCache + // 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 ); + $restore(); + if ( !$status->isOK() ) { throw new MWException( $status->getWikiText( false, false, 'en' ) ); }