<?php
+
+use MediaWiki\MediaWikiServices;
+
/**
* Although marked as a stub, can work independently.
*
$tmpGlobals['wgParserCacheType'] = CACHE_NONE;
$tmpGlobals['wgCapitalLinks'] = true;
$tmpGlobals['wgNoFollowLinks'] = true;
- $tmpGlobals['wgNoFollowDomainExceptions'] = [];
+ $tmpGlobals['wgNoFollowDomainExceptions'] = [ 'no-nofollow.org' ];
$tmpGlobals['wgExternalLinkTarget'] = false;
$tmpGlobals['wgThumbnailScriptPath'] = false;
$tmpGlobals['wgUseImageResize'] = true;
$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';
$this->djVuSupport = new DjVuSupport();
// Tidy support
$this->tidySupport = new TidySupport();
- $tmpGlobals['wgTidyConfig'] = null;
+ $tmpGlobals['wgTidyConfig'] = $this->tidySupport->getConfig();
$tmpGlobals['wgUseTidy'] = false;
- $tmpGlobals['wgDebugTidy'] = false;
- $tmpGlobals['wgTidyConf'] = $IP . '/includes/tidy/tidy.conf';
- $tmpGlobals['wgTidyOpts'] = '';
- $tmpGlobals['wgTidyInternal'] = $this->tidySupport->isInternal();
$this->setMwGlobals( $tmpGlobals );
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();
], $this->db->timestamp( '20010115123500' ), $user );
}
- # A DjVu file
+ $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Audio.oga' ) );
+ if ( !$this->db->selectField( 'image', '1', [ 'img_name' => $image->getName() ] ) ) {
+ $image->recordUpload2( '', 'An awesome hitsong ', 'Will it play', [
+ 'size' => 12345,
+ 'width' => 0,
+ 'height' => 0,
+ 'bits' => 0,
+ 'media_type' => MEDIATYPE_AUDIO,
+ 'mime' => 'application/ogg',
+ 'metadata' => serialize( [] ),
+ 'sha1' => Wikimedia\base_convert( '', 16, 36, 32 ),
+ 'fileExists' => true
+ ], $this->db->timestamp( '20010115123500' ), $user );
+ }
+
# A DjVu file
$image = wfLocalFile( Title::makeTitle( NS_FILE, 'LoremIpsum.djvu' ) );
if ( !$this->db->selectField( 'image', '1', [ 'img_name' => $image->getName() ] ) ) {
'wgMathDirectory' => $uploadDir . '/math',
'wgDefaultLanguageVariant' => $variant,
'wgLinkHolderBatchSize' => $linkHolderBatchSize,
- 'wgUseTidy' => isset( $opts['tidy'] ),
+ 'wgUseTidy' => false,
+ 'wgTidyConfig' => isset( $opts['tidy'] ) ? $this->tidySupport->getConfig() : null
];
if ( $config ) {
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 );