annotate cake/tests/cases/libs/view/helpers/number.test.php @ 0:261e66bd5a0c

hg init
author Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
date Sun, 24 Jul 2011 21:08:31 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 <?php
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 * NumberHelperTest file
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 * PHP versions 4 and 5
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 * CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 * Licensed under The Open Group Test Suite License
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 * Redistributions of files must retain the above copyright notice.
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 * @package cake
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 * @subpackage cake.tests.cases.libs.view.helpers
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 * @since CakePHP(tm) v 1.2.0.4206
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 App::import('Helper', 'Number');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 * NumberHelperTest class
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 * @package cake
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 * @subpackage cake.tests.cases.libs.view.helpers
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 class NumberHelperTest extends CakeTestCase {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 * helper property
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 * @var mixed null
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 var $helper = null;
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 * setUp method
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 function startTest() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 $this->Number =& new NumberHelper();
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 * tearDown method
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 function endTest() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 unset($this->Number);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 * testFormatAndCurrency method
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 function testFormat() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 $value = '100100100';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 $result = $this->Number->format($value, '#');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 $expected = '#100,100,100';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 $result = $this->Number->format($value, 3);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 $expected = '100,100,100.000';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 $result = $this->Number->format($value);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 $expected = '100,100,100';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 $result = $this->Number->format($value, '-');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 $expected = '100-100-100';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 * Test currency method.
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 function testCurrency() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 $value = '100100100';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 $result = $this->Number->currency($value);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 $expected = '$100,100,100.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 $result = $this->Number->currency($value, '#');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 $expected = '#100,100,100.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 $result = $this->Number->currency($value, false);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 $expected = '100,100,100.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 $result = $this->Number->currency($value, 'USD');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 $expected = '$100,100,100.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 $result = $this->Number->currency($value, 'EUR');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 $expected = '&#8364;100.100.100,00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 $result = $this->Number->currency($value, 'GBP');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 $expected = '&#163;100,100,100.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 $result = $this->Number->currency($value, '', array('thousands' =>' ', 'after' => '€', 'decimals' => ',', 'zero' => 'Gratuit'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 $expected = '100 100 100,00€';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 $result = $this->Number->currency(1000.45, NULL, array('after'=>'øre','before'=>'Kr. ','decimals'=>',','thousands'=>'.'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 $expected = 'Kr. 1.000,45';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 $this->assertEqual($expected,$result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 $result = $this->Number->currency(0.5, 'USD');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 $expected = '50c';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 $this->assertEqual($expected,$result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 $result = $this->Number->currency(0.5, NULL, array('after'=>'øre'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 $expected = '50øre';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 $this->assertEqual($expected,$result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 * Test adding currency format options to the number helper
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 function testCurrencyAddFormat() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 $this->Number->addFormat('NOK', array('before' => 'Kr. '));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 $result = $this->Number->currency(1000, 'NOK');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 $expected = 'Kr. 1,000.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 $this->assertEqual($expected,$result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 $this->Number->addFormat('Other', array('before' => '$$ ', 'after' => 'c!'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 $result = $this->Number->currency(0.22, 'Other');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 $expected = '22c!';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 $this->assertEqual($expected,$result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 $result = $this->Number->currency(-10, 'Other');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 $expected = '($$ 10.00)';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 $this->assertEqual($expected,$result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 * testCurrencyPositive method
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 function testCurrencyPositive() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 $value = '100100100';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 $result = $this->Number->currency($value);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 $expected = '$100,100,100.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 $result = $this->Number->currency($value, 'USD', array('before'=> '#'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 $expected = '#100,100,100.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 $result = $this->Number->currency($value, false);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 $expected = '100,100,100.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 $result = $this->Number->currency($value, 'USD');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 $expected = '$100,100,100.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 $result = $this->Number->currency($value, 'EUR');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 $expected = '&#8364;100.100.100,00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 $result = $this->Number->currency($value, 'GBP');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 $expected = '&#163;100,100,100.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 * testCurrencyNegative method
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 function testCurrencyNegative() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 $value = '-100100100';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 $result = $this->Number->currency($value);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 $expected = '($100,100,100.00)';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 $result = $this->Number->currency($value, 'EUR');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 $expected = '(&#8364;100.100.100,00)';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 $result = $this->Number->currency($value, 'GBP');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 $expected = '(&#163;100,100,100.00)';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 $result = $this->Number->currency($value, 'USD', array('negative'=>'-'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 $expected = '-$100,100,100.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 $result = $this->Number->currency($value, 'EUR', array('negative'=>'-'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 $expected = '-&#8364;100.100.100,00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 $result = $this->Number->currency($value, 'GBP', array('negative'=>'-'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 $expected = '-&#163;100,100,100.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 * testCurrencyCentsPositive method
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 function testCurrencyCentsPositive() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 $value = '0.99';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 $result = $this->Number->currency($value, 'USD');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 $expected = '99c';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 $result = $this->Number->currency($value, 'EUR');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 $expected = '&#8364;0,99';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 $result = $this->Number->currency($value, 'GBP');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 $expected = '99p';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 * testCurrencyCentsNegative method
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 function testCurrencyCentsNegative() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 $value = '-0.99';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 $result = $this->Number->currency($value, 'USD');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 $expected = '(99c)';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 $result = $this->Number->currency($value, 'EUR');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 $expected = '(&#8364;0,99)';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 $result = $this->Number->currency($value, 'GBP');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 $expected = '(99p)';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 $result = $this->Number->currency($value, 'USD', array('negative'=>'-'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 $expected = '-99c';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 $result = $this->Number->currency($value, 'EUR', array('negative'=>'-'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 $expected = '-&#8364;0,99';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 $result = $this->Number->currency($value, 'GBP', array('negative'=>'-'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 $expected = '-99p';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 * testCurrencyZero method
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 function testCurrencyZero() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 $value = '0';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 $result = $this->Number->currency($value, 'USD');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 $expected = '$0.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 $result = $this->Number->currency($value, 'EUR');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 $expected = '&#8364;0,00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 $result = $this->Number->currency($value, 'GBP');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 $expected = '&#163;0.00';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 $result = $this->Number->currency($value, 'GBP', array('zero' => 'FREE!'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 $expected = 'FREE!';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 * testCurrencyOptions method
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 function testCurrencyOptions() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 $value = '1234567.89';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
315
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 $result = $this->Number->currency($value, null, array('before' => 'GBP'));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 $expected = 'GBP1,234,567.89';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 $result = $this->Number->currency($value, 'GBP', array('places' => 0));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 $expected = '&#163;1,234,568';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
323
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 $result = $this->Number->currency('1234567.8912345', null, array('before' => 'GBP', 'places' => 3));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 $expected = 'GBP1,234,567.891';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 $result = $this->Number->currency('650.120001', null, array('before' => 'GBP', 'places' => 4));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 $expected = 'GBP650.1200';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
331
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 $result = $this->Number->currency($value, 'GBP', array('escape' => true));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 $expected = '&amp;#163;1,234,567.89';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 $result = $this->Number->currency('0.35', 'USD', array('after' => false));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 $expected = '$0.35';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
339
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 $result = $this->Number->currency('0.35', 'GBP', array('after' => false));
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 $expected = '&#163;0.35';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 $result = $this->Number->currency('0.35', 'GBP');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 $expected = '35p';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
347
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 $result = $this->Number->currency('0.35', 'EUR');
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 $expected = '&#8364;0,35';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 * testToReadableSize method
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 function testToReadableSize() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 $result = $this->Number->toReadableSize(0);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 $expected = '0 Bytes';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
363
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 $result = $this->Number->toReadableSize(1);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 $expected = '1 Byte';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 $result = $this->Number->toReadableSize(45);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
369 $expected = '45 Bytes';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
371
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 $result = $this->Number->toReadableSize(1023);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 $expected = '1023 Bytes';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
375
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 $result = $this->Number->toReadableSize(1024);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 $expected = '1 KB';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 $result = $this->Number->toReadableSize(1024*512);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 $expected = '512 KB';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 $result = $this->Number->toReadableSize(1024*1024-1);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 $expected = '1.00 MB';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
387
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 $result = $this->Number->toReadableSize(1024*1024*512);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 $expected = '512.00 MB';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
391
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 $result = $this->Number->toReadableSize(1024*1024*1024-1);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 $expected = '1.00 GB';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
395
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 $result = $this->Number->toReadableSize(1024*1024*1024*512);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 $expected = '512.00 GB';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
398 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
399
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 $result = $this->Number->toReadableSize(1024*1024*1024*1024-1);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 $expected = '1.00 TB';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
403
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 $result = $this->Number->toReadableSize(1024*1024*1024*1024*512);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 $expected = '512.00 TB';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 $result = $this->Number->toReadableSize(1024*1024*1024*1024*1024-1);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 $expected = '1024.00 TB';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 $result = $this->Number->toReadableSize(1024*1024*1024*1024*1024*1024);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 $expected = (1024 * 1024) . '.00 TB';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 $this->assertEqual($expected, $result);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
416
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 /**
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 * testToPercentage method
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 *
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 * @access public
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 * @return void
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 */
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 function testToPercentage() {
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 $result = $this->Number->toPercentage(45, 0);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 $expected = '45%';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 $this->assertEqual($result, $expected);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
427
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 $result = $this->Number->toPercentage(45, 2);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 $expected = '45.00%';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 $this->assertEqual($result, $expected);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
431
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 $result = $this->Number->toPercentage(0, 0);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 $expected = '0%';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 $this->assertEqual($result, $expected);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
435
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 $result = $this->Number->toPercentage(0, 4);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 $expected = '0.0000%';
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 $this->assertEqual($result, $expected);
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 }
261e66bd5a0c hg init
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
440 }