diff --git a/src/Utils/FormatUtils.php b/src/Utils/FormatUtils.php index cc7cc3a1..ec202de1 100644 --- a/src/Utils/FormatUtils.php +++ b/src/Utils/FormatUtils.php @@ -268,6 +268,7 @@ public static function getNumberFormatter( ): \NumberFormatter { $hash = self::hashCode($style, $digits, $roundingMode, $percentSymbol); if (!isset(self::$numberFormatters[$hash])) { + \Locale::setDefault(self::DEFAULT_LOCALE); $formatter = new \NumberFormatter(\Locale::getDefault(), $style); $formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $digits); $formatter->setAttribute(\NumberFormatter::ROUNDING_MODE, $roundingMode); diff --git a/tests/Utils/FormatUtilsTest.php b/tests/Utils/FormatUtilsTest.php index 8242601d..5ffaeb2c 100644 --- a/tests/Utils/FormatUtilsTest.php +++ b/tests/Utils/FormatUtilsTest.php @@ -308,10 +308,6 @@ public function testFormatId(int|float|string|null $number, string $expected): v #[DataProvider('getIntegers')] public function testFormatInteger(\Countable|array|int|float|string|null $number, string $expected): void { - if (!$this->updateLocale()) { - self::markTestSkipped('Unable to set locale to "fr_CH".'); - } - $actual = FormatUtils::formatInt($number); self::assertSame($expected, $actual); } @@ -378,9 +374,4 @@ private static function createDate(): \DateTimeInterface { return new \DateTime(self::DATE_TIME, new \DateTimeZone(FormatUtils::DEFAULT_TIME_ZONE)); } - - private function updateLocale(): bool - { - return false !== \ini_set('intl.default_locale', FormatUtils::DEFAULT_LOCALE); - } }