mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Setup: Fix sizes being displayed as bits instead of bytes
This commit is contained in:
@@ -982,7 +982,7 @@ class SetupUtils
|
||||
|
||||
public static function HumanReadableSize($fBytes)
|
||||
{
|
||||
$aSizes = array('bytes', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Hb');
|
||||
$aSizes = array('bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'HB');
|
||||
$index = 0;
|
||||
while (($fBytes > 1000) && ($index < count($aSizes))) {
|
||||
$index++;
|
||||
|
||||
@@ -79,5 +79,46 @@ class SetupUtilsTest extends ItopTestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider HumanReadableSizeProvider
|
||||
*/
|
||||
public function testHumanReadableSize($fBytes, $sExpected)
|
||||
{
|
||||
$sOutput = SetupUtils::HumanReadableSize($fBytes);
|
||||
$this->assertEquals($sExpected, $sOutput);
|
||||
}
|
||||
|
||||
public function HumanReadableSizeProvider(): array
|
||||
{
|
||||
return [
|
||||
'10 bytes' => [
|
||||
10,
|
||||
'10 bytes',
|
||||
],
|
||||
'10 kilobytes' => [
|
||||
10 * 1024,
|
||||
'10.24 KB',
|
||||
],
|
||||
'10 megabytes' => [
|
||||
10 * 1024 * 1024,
|
||||
'10.49 MB',
|
||||
],
|
||||
'10 gigabytes' => [
|
||||
10 * 1024 * 1024 * 1024,
|
||||
'10.74 GB',
|
||||
],
|
||||
'10 terabytes' => [
|
||||
10 * 1024 * 1024 * 1024 * 1024,
|
||||
'11.00 TB',
|
||||
],
|
||||
'10 petabytes' => [
|
||||
10 * 1024 * 1024 * 1024 * 1024 * 1024,
|
||||
'11.26 PB',
|
||||
],
|
||||
'10 heptabytes' => [
|
||||
10 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024,
|
||||
'11.53 HB',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user