Fixing problem with handling "0" in NumberHelper::toReadableSize() (ticket #2654)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5195 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
dho 2007-05-26 07:22:19 +00:00
parent 24dd6ddb0a
commit a357f30cda
2 changed files with 8 additions and 2 deletions

View file

@ -58,6 +58,8 @@ class NumberHelper extends AppHelper {
*/ */
function toReadableSize($size) { function toReadableSize($size) {
switch($size) { switch($size) {
case 0:
return '0 Bytes';
case 1: case 1:
return '1 Byte'; return '1 Byte';
case $size < 1024: case $size < 1024:

View file

@ -69,8 +69,12 @@ class NumberTest extends UnitTestCase {
$result = $this->Helper->currency($value, false); $result = $this->Helper->currency($value, false);
$expected = '100,100,100.00'; $expected = '100,100,100.00';
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);
}
function testToReadableSize() {
$result = $this->Helper->toReadableSize(0);
$expected = '0 Bytes';
$this->assertEqual($expected, $result);
} }
function tearDown() { function tearDown() {