X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22sites_tous%22%29%20.%20%22?a=blobdiff_plain;f=tests%2Fphpunit%2FMediaWikiTestCase.php;h=287d28c3b99482db38a7b02f271696669750c406;hb=a4e8bea57d9dbf2b64fa662ec408cf48f61bfe18;hp=feab0df4515ffcc0c5959c88a4116398a4088c0e;hpb=079a0c4caac91f2ca908a8127b37d377643fc7dc;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index feab0df451..287d28c3b9 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -100,6 +100,14 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { */ private $mwGlobalsToUnset = []; + /** + * Holds original values of ini settings to be restored + * in tearDown(). + * @see setIniSettings() + * @var array + */ + private $iniSettings = []; + /** * Holds original loggers which have been replaced by setLogger() * @var LoggerInterface[] @@ -573,6 +581,9 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { foreach ( $this->mwGlobalsToUnset as $value ) { unset( $GLOBALS[$value] ); } + foreach ( $this->iniSettings as $name => $value ) { + ini_set( $name, $value ); + } if ( array_key_exists( 'wgExtraNamespaces', $this->mwGlobals ) || in_array( 'wgExtraNamespaces', $this->mwGlobalsToUnset ) @@ -722,6 +733,18 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { } } + /** + * Set an ini setting for the duration of the test + * @param string $name Name of the setting + * @param string $value Value to set + * @since 1.32 + */ + protected function setIniSetting( $name, $value ) { + $original = ini_get( $name ); + $this->iniSettings[$name] = $original; + ini_set( $name, $value ); + } + /** * Must be called whenever namespaces are changed, e.g., $wgExtraNamespaces is altered. * Otherwise old namespace data will lurk and cause bugs.