X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FMediaWikiTestCase.php;h=27f1454dca2472bc0d06ebedf9bfabd67131641d;hb=356b3420d6908f91510aa0cd94f3a363be7f8999;hp=e0a7ea367e64d898ffb4e64a3981cade080fadbd;hpb=5b45919b07f36a78172c19d54a85233c62a2d951;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index e0a7ea367e..27f1454dca 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -341,7 +341,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { // TODO: move global state into MediaWikiServices RequestContext::resetMain(); - MediaHandler::resetCache(); if ( session_id() !== '' ) { session_write_close(); session_id( '' ); @@ -530,7 +529,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { // TODO: move global state into MediaWikiServices RequestContext::resetMain(); - MediaHandler::resetCache(); if ( session_id() !== '' ) { session_write_close(); session_id( '' ); @@ -1650,32 +1648,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } } - /** - * Check whether we have the 'gzip' commandline utility, will skip - * the test whenever "gzip -V" fails. - * - * Result is cached at the process level. - * - * @return bool - * - * @since 1.21 - */ - protected function checkHasGzip() { - static $haveGzip; - - if ( $haveGzip === null ) { - $retval = null; - wfShellExec( 'gzip -V', $retval ); - $haveGzip = ( $retval === 0 ); - } - - if ( !$haveGzip ) { - $this->markTestSkipped( "Skip test, requires the gzip utility in PATH" ); - } - - return $haveGzip; - } - /** * Check if $extName is a loaded PHP extension, will skip the * test whenever it is not loaded. @@ -1801,4 +1773,15 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { return $buffer; } + /** + * Create a temporary hook handler which will be reset by tearDown. + * This replaces other handlers for the same hook. + * @param string $hookName Hook name + * @param mixed $handler Value suitable for a hook handler + * @since 1.28 + */ + protected function setTemporaryHook( $hookName, $handler ) { + $this->mergeMwGlobalArrayValue( 'wgHooks', [ $hookName => [ $handler ] ] ); + } + }