<?php
+
+use MediaWiki\MediaWikiServices;
+
/**
* Although marked as a stub, can work independently.
*
$tmpGlobals['wgStyleDirectory'] = "$IP/skins";
}
- # Replace all media handlers with a mock. We do not need to generate
- # actual thumbnails to do parser testing, we only care about receiving
- # a ThumbnailImage properly initialized.
- global $wgMediaHandlers;
- foreach ( $wgMediaHandlers as $type => $handler ) {
- $tmpGlobals['wgMediaHandlers'][$type] = 'MockBitmapHandler';
- }
- // Vector images have to be handled slightly differently
- $tmpGlobals['wgMediaHandlers']['image/svg+xml'] = 'MockSvgHandler';
-
- // DjVu images have to be handled slightly differently
- $tmpGlobals['wgMediaHandlers']['image/vnd.djvu'] = 'MockDjVuHandler';
-
- // Ogg video/audio increasingly more differently
- $tmpGlobals['wgMediaHandlers']['application/ogg'] = 'MockOggHandler';
-
$tmpHooks = $wgHooks;
$tmpHooks['ParserTestParser'][] = 'ParserTestParserHook::setup';
$tmpHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
$wgContLang->resetNamespaces(); # reset namespace cache
ParserTest::resetTitleServices();
+ MediaWikiServices::getInstance()->disableService( 'MediaHandlerFactory' );
+ MediaWikiServices::getInstance()->redefineService(
+ 'MediaHandlerFactory',
+ function() {
+ return new MockMediaHandlerFactory();
+ }
+ );
}
protected function tearDown() {
// Restore message cache (temporary pages and $wgUseDatabaseMessages)
MessageCache::destroyInstance();
+ MediaWikiServices::getInstance()->resetServiceForTesting( 'MediaHandlerFactory' );
parent::tearDown();
if ( $this->regex != '' && !preg_match( '/' . $this->regex . '/', $desc ) ) {
$this->assertTrue( true ); // XXX: don't flood output with "test made no assertions"
// $this->markTestSkipped( 'Filtered out by the user' );
+ $this->teardownGlobals();
return;
}
// parser tests frequently assume that the main namespace contains wikitext.
// @todo When setting up pages, force the content model. Only skip if
// $wgtContentModelUseDB is false.
+ $this->teardownGlobals();
$this->markTestSkipped( "Main namespace does not support wikitext,"
. "skipping parser test: $desc" );
}
global $wgTexvc;
if ( !isset( $wgTexvc ) ) {
+ $this->teardownGlobals();
$this->markTestSkipped( "SKIPPED: \$wgTexvc is not set" );
} elseif ( !is_executable( $wgTexvc ) ) {
+ $this->teardownGlobals();
$this->markTestSkipped( "SKIPPED: texvc binary does not exist"
. " or is not executable.\n"
. "Current configuration is:\n\$wgTexvc = '$wgTexvc'" );
if ( isset( $opts['djvu'] ) ) {
if ( !$this->djVuSupport->isEnabled() ) {
+ $this->teardownGlobals();
$this->markTestSkipped( "SKIPPED: djvu binaries do not exist or are not executable.\n" );
}
}
if ( isset( $opts['tidy'] ) ) {
if ( !$this->tidySupport->isEnabled() ) {
+ $this->teardownGlobals();
$this->markTestSkipped( "SKIPPED: tidy extension is not installed.\n" );
} else {
$options->setTidy( true );