Skip to content

Commit

Permalink
UString tests fix
Browse files Browse the repository at this point in the history
  • Loading branch information
misantron committed Mar 1, 2015
1 parent a38d277 commit 72084e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Utility/UString.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public static function fileSize($bytes, $precision = 2)
if($bytes > PHP_INT_MAX){
throw new InvalidArgumentException('Bytes size exceeds PHP_INT_MAX.');
}
$translations = array_values(static::loadTranslations(__FUNCTION__));
$translations = static::loadTranslations(__FUNCTION__);
$translations = array_values($translations);
$factor = (int)floor((strlen($bytes) - 1) / 3);
return round(($bytes / pow(1024, $factor)), $precision) . ' ' . $translations[$factor];
}
Expand Down
6 changes: 3 additions & 3 deletions tests/UStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ public function testSlugify()
public function testFileSize()
{
try {
UString::fileSize(PHP_INT_MAX + 4);
$this->setExpectedException('\\Utility\\Exception\\InvalidArgumentException');
$bytes = PHP_INT_MAX + 36;
UString::fileSize($bytes);
} catch(InvalidArgumentException $e){
$this->assertInstanceOf('\\Utility\\Exception\\InvalidArgumentException', $e);
$this->assertInstanceOf('Utility\Exception\InvalidArgumentException', $e);
$this->assertEquals('Bytes size exceeds PHP_INT_MAX.', $e->getMessage());
}

Expand Down

0 comments on commit 72084e1

Please sign in to comment.