* @ingroup Testing
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\ScopedCallback;
/**
* @ingroup Testing
/**
* Our connection to the database
- * @var DatabaseBase
+ * @var Database
*/
private $db;
*/
private $dbClone;
- /**
- * @var DjVuSupport
- */
- private $djVuSupport;
-
/**
* @var TidySupport
*/
$this->runDisabled = !empty( $options['run-disabled'] );
$this->runParsoid = !empty( $options['run-parsoid'] );
- $this->djVuSupport = new DjVuSupport();
$this->tidySupport = new TidySupport( !empty( $options['use-tidy-config'] ) );
if ( !$this->tidySupport->isEnabled() ) {
$this->recorder->warning(
// 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
* @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 );
}
$this->setupDone[$funcName] = true;
return function () use ( $funcName ) {
- wfDebug( "markSetupDone unmarked $funcName" );
$this->setupDone[$funcName] = false;
};
}
$user = $context->getUser();
$options = ParserOptions::newFromContext( $context );
- if ( isset( $opts['djvu'] ) ) {
- if ( !$this->djVuSupport->isEnabled() ) {
- $this->recorder->skipped( $test,
- 'djvu binaries do not exist or are not executable' );
- return false;
- }
- }
-
if ( isset( $opts['tidy'] ) ) {
if ( !$this->tidySupport->isEnabled() ) {
$this->recorder->skipped( $test, 'tidy extension is not installed' );
};
// Set content language. This invalidates the magic word cache and title services
- wfDebug( "Setting up language $langCode" );
$lang = Language::factory( $langCode );
$setup['wgContLang'] = $lang;
$reset = function () {
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' ) );
}
// The RepoGroup cache is invalidated by the creation of file redirects
- if ( $title->getNamespace() === NS_IMAGE ) {
+ if ( $title->inNamespace( NS_FILE ) ) {
RepoGroup::singleton()->clearCache( $title );
}
}