zendframework / zend-i18n

I18n component from Zend Framework
BSD 3-Clause "New" or "Revised" License
65 stars 49 forks source link

Fix problem of decimals always visible when using currencyFormat view helper #52

Closed GeeH closed 5 years ago

GeeH commented 8 years ago

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html


Original Issue: https://github.com/zendframework/zendframework/issues/6852 User: @Gawel1 Created On: 2014-11-07T11:02:04Z Updated At: 2014-11-17T15:06:04Z Body Apply comment visible in http://php.net/manual/en/numberformatter.formatcurrency.php :

When you want to format currency's without sub units and the currency is not the one used by the given locale you need to set the currency code before as TextAttribute BEFORE setting the NumberFormatter::FRACTION_DIGITS

$fmt = new NumberFormatter('en_US', NumberFormatter::CURRENCY);
$fmt->setTextAttribute(NumberFormatter::CURRENCY_CODE, 'EUR');
$fmt->setAttribute(NumberFormatter::FRACTION_DIGITS, 0);
$fmt->formatCurrency(100, 'EUR');

Comment

User: @DASPRiD Created On: 2014-11-07T11:55:04Z Updated At: 2014-11-07T11:55:04Z Body Please add a unit test for that.


Comment

User: @adamlundrigan Created On: 2014-11-14T03:33:08Z Updated At: 2014-11-14T03:33:08Z Body @Gawel1 your commit breaks two other tests:

There were 2 failures:

1) ZendTest\I18n\View\Helper\CurrencyFormatTest::testBasic with data set #15 ('de_DE', 'RUB', false, 1234567.8912345679, NULL, '1.234.567,89 RUB')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'1.234.567,89RUB'
+'1.234.568RUB'

./zf2/tests/ZendTest/I18n/View/Helper/CurrencyFormatTest.php:125
./zf2/tests/ZendTest/I18n/View/Helper/CurrencyFormatTest.php:83

2) ZendTest\I18n\View\Helper\CurrencyFormatTest::testSettersProvideDefaults with data set #15 ('de_DE', 'RUB', false, 1234567.8912345679, NULL, '1.234.567,89 RUB')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'1.234.567,89RUB'
+'1.234.568RUB'

Comment

User: @adamlundrigan Created On: 2014-11-17T15:03:24Z Updated At: 2014-11-17T15:06:04Z Body Is this the same issue as #2318 (Allow to remove decimals in CurrencyFormat)? That turned out to be a bug in ICU (fixed in 4.8.x).


michalbundyra commented 5 years ago

@Gawel1 I cannot replicate the issue. Based on the comments it might be resolved. If the issue is still present please provide a failing test case. Thanks!