Skip to content
Permalink
Browse files

Adding test cases from #5630

  • Loading branch information...
markstory committed Sep 11, 2009
1 parent 5f6015c commit 818e7340f784263852b6249a884b1acc4ee6cbd2
Showing with 39 additions and 11 deletions.
  1. +39 −11 cake/tests/cases/libs/view/helpers/number.test.php
@@ -82,7 +82,15 @@ function testFormatAndCurrency() {
$result = $this->Number->format($value, '-');
$expected = '100-100-100';
$this->assertEqual($expected, $result);
}
/**
* Test currency method.
*
* @access public
* @return void
*/
function testCurrency() {
$result = $this->Number->currency($value);
$expected = '$100,100,100.00';
$this->assertEqual($expected, $result);
@@ -111,6 +119,33 @@ function testFormatAndCurrency() {
$expected = '100 100 100,00€';
$this->assertEqual($expected, $result);
$result = $this->Number->currency(1000.45, NULL, array('after'=>'øre','before'=>'Kr. ','decimals'=>',','thousands'=>'.'));
$expected = 'Kr. 1.000,45';
$this->assertEqual($expected,$result);
$result = $this->Number->currency(0.5, 'USD');
$expected = '50c';
$this->assertEqual($expected,$result);
$result = $this->Number->currency(0.5, NULL, array('after'=>'øre'));
$expected = '50øre';
$this->assertEqual($expected,$result);
}
/**
* Test adding currency format options to the number helper
*
* @access public
* @return void
*/
function testCurrencyAddFormat() {
if ($this->skipIf(true, 'NumberHelper::addFormat Not implemented')) {
return;
}
$this->Number->addFormat('NOK',array('before'=>'Kr. '));
$result = $this->Number->currency(1000,'NOK');
$expected = 'Kr. 1,000.00';
$this->assertEqual($expected,$result);
}
/**
@@ -202,7 +237,6 @@ function testCurrencyCentsPositive() {
$result = $this->Number->currency($value, 'GBP');
$expected = '99p';
$this->assertEqual($expected, $result);
}
/**
@@ -237,7 +271,6 @@ function testCurrencyCentsNegative() {
$result = $this->Number->currency($value, 'GBP', array('negative'=>'-'));
$expected = '-99p';
$this->assertEqual($expected, $result);
}
/**
@@ -261,10 +294,9 @@ function testCurrencyZero() {
$expected = '£0.00';
$this->assertEqual($expected, $result);
$result = $this->Number->currency($value, 'GBP', array('zero'=> 'FREE!'));
$result = $this->Number->currency($value, 'GBP', array('zero' => 'FREE!'));
$expected = 'FREE!';
$this->assertEqual($expected, $result);
}
/**
@@ -276,18 +308,17 @@ function testCurrencyZero() {
function testCurrencyOptions() {
$value = '1234567.89';
$result = $this->Number->currency($value, null, array('before'=>'GBP'));
$result = $this->Number->currency($value, null, array('before' => 'GBP'));
$expected = 'GBP1,234,567.89';
$this->assertEqual($expected, $result);
$result = $this->Number->currency($value, 'GBP', array('places'=>0));
$result = $this->Number->currency($value, 'GBP', array('places' => 0));
$expected = '£1,234,568';
$this->assertEqual($expected, $result);
$result = $this->Number->currency($value, 'GBP', array('escape'=>true));
$result = $this->Number->currency($value, 'GBP', array('escape' => true));
$expected = '£1,234,567.89';
$this->assertEqual($expected, $result);
}
/**
@@ -376,9 +407,6 @@ function testToPercentage() {
$result = $this->Number->toPercentage(0, 4);
$expected = '0.0000%';
$this->assertEqual($result, $expected);
}
}
?>

0 comments on commit 818e734

Please sign in to comment.
You can’t perform that action at this time.