'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",
--- /dev/null
+<?php
+
+/**
+ * A parser used during article insertion which does nothing, to avoid
+ * unnecessary log noise and other interference with debugging.
+ */
+class ParserTestMockParser {
+ public function preSaveTransform( $text, Title $title, User $user,
+ ParserOptions $options, $clearState = true
+ ) {
+ return $text;
+ }
+
+ public function parse(
+ $text, Title $title, ParserOptions $options,
+ $linestart = true, $clearState = true, $revid = null
+ ) {
+ return new ParserOutput;
+ }
+}
* @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 );
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' ) );
}