function TestCase::setLocale
This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.
@codeCoverageIgnore
Throws
File
-
vendor/
phpunit/ phpunit/ src/ Framework/ TestCase.php, line 1242
Class
- TestCase
- @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Namespace
PHPUnit\FrameworkCode
protected function setLocale(mixed ...$arguments) : void {
if (count($arguments) < 2) {
throw new Exception();
}
[
$category,
$locale,
] = $arguments;
if (!in_array($category, self::LOCALE_CATEGORIES, true)) {
throw new Exception();
}
if (!is_array($locale) && !is_string($locale)) {
throw new Exception();
}
$this->locale[$category] = setlocale($category, '0');
$result = setlocale(...$arguments);
if ($result === false) {
throw new Exception('The locale functionality is not implemented on your platform, ' . 'the specified locale does not exist or the category name is ' . 'invalid.');
}
}