2007-05-24 20:45:27 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
|
|
* Short description for file.
|
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
|
|
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
|
|
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
|
|
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.view.helpers
|
|
|
|
* @since CakePHP(tm) v 1.2.0.4206
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
|
|
|
*/
|
2007-07-08 01:17:57 +00:00
|
|
|
require_once CAKE.'app_helper.php';
|
|
|
|
uses('view'.DS.'helper', 'view'.DS.'helpers'.DS.'number');
|
2007-05-24 20:45:27 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.view.helpers
|
|
|
|
*/
|
|
|
|
class NumberTest extends UnitTestCase {
|
|
|
|
var $helper = null;
|
|
|
|
|
|
|
|
|
|
|
|
function setUp() {
|
2007-07-08 01:17:57 +00:00
|
|
|
$this->Number =& new NumberHelper();
|
2007-05-24 20:45:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testFormatAndCurrency() {
|
2007-05-24 20:51:37 +00:00
|
|
|
$value = '100100100';
|
2007-05-24 20:45:27 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Number->format($value, '#');
|
2007-05-24 20:45:27 +00:00
|
|
|
$expected = '#100,100,100';
|
|
|
|
$this->assertEqual($expected, $result);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Number->format($value);
|
2007-05-24 20:45:27 +00:00
|
|
|
$expected = '100,100,100';
|
|
|
|
$this->assertEqual($expected, $result);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Number->format($value, '-');
|
2007-05-24 20:45:27 +00:00
|
|
|
$expected = '100-100-100';
|
|
|
|
$this->assertEqual($expected, $result);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Number->currency($value);
|
2007-05-24 20:45:27 +00:00
|
|
|
$expected = '$100,100,100.00';
|
|
|
|
$this->assertEqual($expected, $result);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Number->currency($value, '#');
|
2007-05-24 20:45:27 +00:00
|
|
|
$expected = '#100,100,100.00';
|
|
|
|
$this->assertEqual($expected, $result);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Number->currency($value, false);
|
2007-05-24 20:45:27 +00:00
|
|
|
$expected = '100,100,100.00';
|
|
|
|
$this->assertEqual($expected, $result);
|
2007-06-21 16:01:11 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Number->currency($value, 'USD');
|
2007-06-21 16:01:11 +00:00
|
|
|
$expected = '$100,100,100.00';
|
|
|
|
$this->assertEqual($expected, $result);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Number->currency($value, 'EUR');
|
2007-06-21 16:01:11 +00:00
|
|
|
$expected = '€100.100.100,00';
|
|
|
|
$this->assertEqual($expected, $result);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Number->currency($value, 'GBP');
|
2007-06-21 16:01:11 +00:00
|
|
|
$expected = '£100,100,100.00';
|
|
|
|
$this->assertEqual($expected, $result);
|
2007-05-24 20:45:27 +00:00
|
|
|
}
|
|
|
|
|
2007-05-26 07:22:19 +00:00
|
|
|
function testToReadableSize() {
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Number->toReadableSize(0);
|
2007-05-26 07:22:19 +00:00
|
|
|
$expected = '0 Bytes';
|
|
|
|
$this->assertEqual($expected, $result);
|
|
|
|
}
|
2007-06-21 16:01:11 +00:00
|
|
|
|
2007-05-24 20:45:27 +00:00
|
|
|
function tearDown() {
|
2007-07-08 01:17:57 +00:00
|
|
|
unset($this->Number);
|
2007-05-24 20:45:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|