From 4d3a1404827e5d49d7e75eb0b92fe2bc0d18ca36 Mon Sep 17 00:00:00 2001 From: SilverFire - Dmitry Naumenko Date: Thu, 6 Dec 2018 17:35:22 +0200 Subject: [PATCH] Fixed additional regression in number formatting Related to https://github.com/yiisoft/yii2/issues/16934 --- framework/i18n/Formatter.php | 1 + tests/framework/i18n/FormatterNumberTest.php | 1 + 2 files changed, 2 insertions(+) diff --git a/framework/i18n/Formatter.php b/framework/i18n/Formatter.php index b2b2615865..3c59242c86 100644 --- a/framework/i18n/Formatter.php +++ b/framework/i18n/Formatter.php @@ -1797,6 +1797,7 @@ class Formatter extends Component return !( (string) $normalizedValue === (string) $value || (string) $normalizedValue === (string)((int) $value) + || (string) $normalizedValue === trim((string) $value, '0') ); } diff --git a/tests/framework/i18n/FormatterNumberTest.php b/tests/framework/i18n/FormatterNumberTest.php index 6b60de1f68..eb10f691a3 100644 --- a/tests/framework/i18n/FormatterNumberTest.php +++ b/tests/framework/i18n/FormatterNumberTest.php @@ -296,6 +296,7 @@ class FormatterNumberTest extends TestCase $this->formatter->locale = 'en-US'; $this->assertSame('$123.00', $this->formatter->asCurrency('123')); $this->assertSame('$123.00', $this->formatter->asCurrency('123.00')); + $this->assertSame('$123.20', $this->formatter->asCurrency('123.20')); $this->assertSame('$123,456.00', $this->formatter->asCurrency('123456')); $this->assertSame('$0.00', $this->formatter->asCurrency('0'));