Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TestCase.php

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

Exception

Deprecated

https://github.com/sebastianbergmann/phpunit/issues/5216

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\Framework

Code

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.');
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal