From 56bf60e61025807648e6e50c4a55f39a0ba32cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20K=C3=BChne?= Date: Wed, 6 Dec 2023 08:37:41 +0100 Subject: [PATCH] Add tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matthias Kühne --- test/View/Helper/CurrencyFormatTest.php | 12 ++++++++++++ test/View/Helper/DateFormatTest.php | 12 ++++++++++++ test/View/Helper/NumberFormatTest.php | 12 ++++++++++++ 3 files changed, 36 insertions(+) diff --git a/test/View/Helper/CurrencyFormatTest.php b/test/View/Helper/CurrencyFormatTest.php index b7206a10..25379fc5 100644 --- a/test/View/Helper/CurrencyFormatTest.php +++ b/test/View/Helper/CurrencyFormatTest.php @@ -108,4 +108,16 @@ public static function assertMbStringEquals(string $expected, string $test, stri $test = str_replace(["\xC2\xA0", ' '], '', $test); self::assertEquals($expected, $test, $message); } + + public function testNoImplicitLocale(): void + { + \Locale::setDefault('de'); + self::assertEquals(Locale::getDefault(), $this->helper->getLocale()); + + \Locale::setDefault('en'); + self::assertEquals(Locale::getDefault(), $this->helper->getLocale()); + + $this->helper->setLocale('es'); + self::assertEquals('es', $this->helper->getLocale()); + } } diff --git a/test/View/Helper/DateFormatTest.php b/test/View/Helper/DateFormatTest.php index 0630cc1b..ae676418 100644 --- a/test/View/Helper/DateFormatTest.php +++ b/test/View/Helper/DateFormatTest.php @@ -292,4 +292,16 @@ public function testIntlCalendarIsHandledAsWell(): void $helper->__invoke($calendar, IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'it_IT', 'dd-MM-Y') ); } + + public function testNoImplicitLocale(): void + { + \Locale::setDefault('de'); + self::assertEquals(Locale::getDefault(), $this->helper->getLocale()); + + \Locale::setDefault('en'); + self::assertEquals(Locale::getDefault(), $this->helper->getLocale()); + + $this->helper->setLocale('es'); + self::assertEquals('es', $this->helper->getLocale()); + } } diff --git a/test/View/Helper/NumberFormatTest.php b/test/View/Helper/NumberFormatTest.php index 8286d1e5..4dcd918a 100644 --- a/test/View/Helper/NumberFormatTest.php +++ b/test/View/Helper/NumberFormatTest.php @@ -196,4 +196,16 @@ public static function assertMbStringEquals(string $expected, string $test, stri $test = str_replace(["\xC2\xA0", ' '], '', $test); self::assertEquals($expected, $test, $message); } + + public function testNoImplicitLocale(): void + { + \Locale::setDefault('de'); + self::assertEquals(Locale::getDefault(), $this->helper->getLocale()); + + \Locale::setDefault('en'); + self::assertEquals(Locale::getDefault(), $this->helper->getLocale()); + + $this->helper->setLocale('es'); + self::assertEquals('es', $this->helper->getLocale()); + } }