Author: fabien
Date: 2010-01-15 16:28:37 +0100 (Fri, 15 Jan 2010)
New Revision: 26681

Modified:
   branches/1.2/lib/i18n/sfNumberFormat.class.php
   branches/1.2/test/unit/helper/NumberHelperTest.php
   branches/1.3/lib/i18n/sfNumberFormat.class.php
   branches/1.3/test/unit/helper/NumberHelperTest.php
   branches/1.4/lib/i18n/sfNumberFormat.class.php
   branches/1.4/test/unit/helper/NumberHelperTest.php
Log:
[1.2, 1.3, 1.4] fixed format_currency is rounding bad (closes #6788)

Modified: branches/1.2/lib/i18n/sfNumberFormat.class.php
===================================================================
--- branches/1.2/lib/i18n/sfNumberFormat.class.php      2010-01-15 14:59:32 UTC 
(rev 26680)
+++ branches/1.2/lib/i18n/sfNumberFormat.class.php      2010-01-15 15:28:37 UTC 
(rev 26681)
@@ -171,13 +171,6 @@
   {
     $string = (string) $string;
 
-    $decimalDigits = $this->formatInfo->DecimalDigits;
-    // if not decimal digits, assume 0 decimal points.
-    if (is_int($decimalDigits) && $decimalDigits > 0)
-    {
-      $string = (string) intval(round(floatval($string), $decimalDigits));
-    }
-
     $dp = strpos($string, '.');
 
     if (is_int($dp))

Modified: branches/1.2/test/unit/helper/NumberHelperTest.php
===================================================================
--- branches/1.2/test/unit/helper/NumberHelperTest.php  2010-01-15 14:59:32 UTC 
(rev 26680)
+++ branches/1.2/test/unit/helper/NumberHelperTest.php  2010-01-15 15:28:37 UTC 
(rev 26681)
@@ -11,7 +11,7 @@
 require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
 require_once(dirname(__FILE__).'/../../../lib/helper/NumberHelper.php');
 
-$t = new lime_test(7, new lime_output_color());
+$t = new lime_test(10, new lime_output_color());
 
 // format_number()
 $t->diag('format_number()');
@@ -26,3 +26,7 @@
 $t->is(format_currency(1200000.10, 'USD', 'en'), 'US$1,200,000.10', 
'format_currency() takes a number as its first argument');
 $t->is(format_currency(1200000.101, 'USD', 'en'), 'US$1,200,000.10', 
'format_currency() takes a number as its first argument');
 $t->is(format_currency('1200000', 'USD', 'en'), 'US$1,200,000.00', 
'format_currency() takes a number as its first argument');
+
+$t->is(format_currency('11.50999', 'USD', 'en'), 'US$11.50', 
'format_currency() takes a number as its first argument');
+$t->is(format_currency('11.50999', 'EUR', 'fr'), '11,50 €', 'format_currency() 
takes a number as its first argument');
+$t->is(format_currency('11.9999464', 'EUR', 'fr'), '11,99 €', 
'format_currency() takes a number as its first argument');

Modified: branches/1.3/lib/i18n/sfNumberFormat.class.php
===================================================================
--- branches/1.3/lib/i18n/sfNumberFormat.class.php      2010-01-15 14:59:32 UTC 
(rev 26680)
+++ branches/1.3/lib/i18n/sfNumberFormat.class.php      2010-01-15 15:28:37 UTC 
(rev 26681)
@@ -171,13 +171,6 @@
   {
     $string = (string) $string;
 
-    $decimalDigits = $this->formatInfo->DecimalDigits;
-    // if not decimal digits, assume 0 decimal points.
-    if (is_int($decimalDigits) && $decimalDigits > 0)
-    {
-      $string = (string) intval(round(floatval($string), $decimalDigits));
-    }
-
     $dp = strpos($string, '.');
 
     if (is_int($dp))

Modified: branches/1.3/test/unit/helper/NumberHelperTest.php
===================================================================
--- branches/1.3/test/unit/helper/NumberHelperTest.php  2010-01-15 14:59:32 UTC 
(rev 26680)
+++ branches/1.3/test/unit/helper/NumberHelperTest.php  2010-01-15 15:28:37 UTC 
(rev 26681)
@@ -11,7 +11,7 @@
 require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
 require_once(dirname(__FILE__).'/../../../lib/helper/NumberHelper.php');
 
-$t = new lime_test(7);
+$t = new lime_test(10);
 
 // format_number()
 $t->diag('format_number()');
@@ -26,3 +26,7 @@
 $t->is(format_currency(1200000.10, 'USD', 'en'), '$1,200,000.10', 
'format_currency() takes a number as its first argument');
 $t->is(format_currency(1200000.101, 'USD', 'en'), '$1,200,000.10', 
'format_currency() takes a number as its first argument');
 $t->is(format_currency('1200000', 'USD', 'en'), '$1,200,000.00', 
'format_currency() takes a number as its first argument');
+
+$t->is(format_currency('11.50999', 'USD', 'en'), '$11.50', 'format_currency() 
takes a number as its first argument');
+$t->is(format_currency('11.50999', 'EUR', 'fr'), '11,50 €', 'format_currency() 
takes a number as its first argument');
+$t->is(format_currency('11.9999464', 'EUR', 'fr'), '11,99 €', 
'format_currency() takes a number as its first argument');

Modified: branches/1.4/lib/i18n/sfNumberFormat.class.php
===================================================================
--- branches/1.4/lib/i18n/sfNumberFormat.class.php      2010-01-15 14:59:32 UTC 
(rev 26680)
+++ branches/1.4/lib/i18n/sfNumberFormat.class.php      2010-01-15 15:28:37 UTC 
(rev 26681)
@@ -171,13 +171,6 @@
   {
     $string = (string) $string;
 
-    $decimalDigits = $this->formatInfo->DecimalDigits;
-    // if not decimal digits, assume 0 decimal points.
-    if (is_int($decimalDigits) && $decimalDigits > 0)
-    {
-      $string = (string) intval(round(floatval($string), $decimalDigits));
-    }
-
     $dp = strpos($string, '.');
 
     if (is_int($dp))

Modified: branches/1.4/test/unit/helper/NumberHelperTest.php
===================================================================
--- branches/1.4/test/unit/helper/NumberHelperTest.php  2010-01-15 14:59:32 UTC 
(rev 26680)
+++ branches/1.4/test/unit/helper/NumberHelperTest.php  2010-01-15 15:28:37 UTC 
(rev 26681)
@@ -11,7 +11,7 @@
 require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
 require_once(dirname(__FILE__).'/../../../lib/helper/NumberHelper.php');
 
-$t = new lime_test(7);
+$t = new lime_test(10);
 
 // format_number()
 $t->diag('format_number()');
@@ -26,3 +26,7 @@
 $t->is(format_currency(1200000.10, 'USD', 'en'), '$1,200,000.10', 
'format_currency() takes a number as its first argument');
 $t->is(format_currency(1200000.101, 'USD', 'en'), '$1,200,000.10', 
'format_currency() takes a number as its first argument');
 $t->is(format_currency('1200000', 'USD', 'en'), '$1,200,000.00', 
'format_currency() takes a number as its first argument');
+
+$t->is(format_currency('11.50999', 'USD', 'en'), '$11.50', 'format_currency() 
takes a number as its first argument');
+$t->is(format_currency('11.50999', 'EUR', 'fr'), '11,50 €', 'format_currency() 
takes a number as its first argument');
+$t->is(format_currency('11.9999464', 'EUR', 'fr'), '11,99 €', 
'format_currency() takes a number as its first argument');

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.


Reply via email to