X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fparser%2FNewParserTest.php;h=ad84c207b20037ae1d6447205cbca2084a0f007c;hb=c2e2afbc900dda1228f8ea6f5a3609d569fce00a;hp=8512572a257f149851fb02589e9d95acb8981f07;hpb=3eebaaffcf25c3779725309570de924ad5bea766;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index 8512572a25..ad84c207b2 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -1,4 +1,7 @@ $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'; @@ -163,12 +150,8 @@ class NewParserTest extends MediaWikiTestCase { $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 ); @@ -181,6 +164,13 @@ class NewParserTest extends MediaWikiTestCase { 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() { @@ -200,6 +190,7 @@ class NewParserTest extends MediaWikiTestCase { // Restore message cache (temporary pages and $wgUseDatabaseMessages) MessageCache::destroyInstance(); + MediaWikiServices::getInstance()->resetServiceForTesting( 'MediaHandlerFactory' ); parent::tearDown(); @@ -452,7 +443,8 @@ class NewParserTest extends MediaWikiTestCase { 'wgMathDirectory' => $uploadDir . '/math', 'wgDefaultLanguageVariant' => $variant, 'wgLinkHolderBatchSize' => $linkHolderBatchSize, - 'wgUseTidy' => isset( $opts['tidy'] ), + 'wgUseTidy' => false, + 'wgTidyConfig' => isset( $opts['tidy'] ) ? $this->tidySupport->getConfig() : null ]; if ( $config ) { @@ -720,6 +712,7 @@ class NewParserTest extends MediaWikiTestCase { 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; } @@ -727,6 +720,7 @@ class NewParserTest extends MediaWikiTestCase { // 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" ); } @@ -757,8 +751,10 @@ class NewParserTest extends MediaWikiTestCase { 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'" ); @@ -767,12 +763,14 @@ class NewParserTest extends MediaWikiTestCase { 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 );