Fix formatting of decimal values when there is no fractionSymbol.

When a currency format does not include a fractionSymbol it should be
able to format fractional values.

Fixes #2253
This commit is contained in:
mark_story 2013-11-09 09:36:38 -05:00
parent 407c420176
commit ada0ec4c77
2 changed files with 30 additions and 17 deletions

View file

@ -335,6 +335,19 @@ class CakeNumberTest extends CakeTestCase {
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
/**
* Test that the default fraction handling does not cause issues.
*
* @return void
*/
public function testCurrencyFractionSymbol() {
$result = $this->Number->currency(0.2, '', array(
'places' => 2,
'decimal' => '.'
));
$this->assertEquals('0.2', $result);
}
/** /**
* Test adding currency format options to the number helper * Test adding currency format options to the number helper
* *

View file

@ -75,7 +75,7 @@ class CakeNumber {
* @var array * @var array
*/ */
protected static $_currencyDefaults = array( protected static $_currencyDefaults = array(
'wholeSymbol' => '', 'wholePosition' => 'before', 'fractionSymbol' => '', 'fractionPosition' => 'after', 'wholeSymbol' => '', 'wholePosition' => 'before', 'fractionSymbol' => false, 'fractionPosition' => 'after',
'zero' => '0', 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()', 'escape' => true, 'zero' => '0', 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()', 'escape' => true,
'fractionExponent' => 2 'fractionExponent' => 2
); );