Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
46b553f0
Commit
46b553f0
authored
Jul 24, 2014
by
Kai Mindermann
Committed by
Alexander Makarov
Jul 24, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes formatter doing one division too much, fixes #4427
parent
f3520187
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
1 deletion
+6
-1
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
Formatter.php
framework/base/Formatter.php
+1
-1
FormatterTest.php
tests/unit/framework/base/FormatterTest.php
+4
-0
No files found.
framework/CHANGELOG.md
View file @
46b553f0
...
...
@@ -71,6 +71,7 @@ Yii Framework 2 Change Log
-
Bug #4342: mssql (dblib) driver does not support getting attributes (tof06)
-
Bug #4409: Upper case letters in subdirectory prefixes of controller IDs were not properly handled (qiangxue)
-
Bug #4412: Formatter used SI Prefixes for base 1024, now uses binary prefixes (kmindi)
-
Bug #4427: Formatter could do one division too much (kmindi)
-
Bug: Fixed inconsistent return of
`\yii\console\Application::runAction()`
(samdark)
-
Bug: URL encoding for the route parameter added to
`\yii\web\UrlManager`
(klimov-paul)
-
Bug: Fixed the bug that requesting protected or private action methods would cause 500 error instead of 404 (qiangxue)
...
...
framework/base/Formatter.php
View file @
46b553f0
...
...
@@ -461,7 +461,7 @@ class Formatter extends Component
$value
=
$value
/
$this
->
sizeFormat
[
'base'
];
$position
++
;
}
while
(
$position
<
6
);
}
while
(
$position
<
5
);
$value
=
round
(
$value
,
$this
->
sizeFormat
[
'decimals'
]);
$formattedValue
=
isset
(
$this
->
sizeFormat
[
'decimalSeparator'
])
?
str_replace
(
'.'
,
$this
->
sizeFormat
[
'decimalSeparator'
],
$value
)
:
$value
;
...
...
tests/unit/framework/base/FormatterTest.php
View file @
46b553f0
...
...
@@ -193,11 +193,13 @@ class FormatterTest extends TestCase
public
function
testAsSize
()
{
// tests for base 1000
$this
->
formatter
->
sizeFormat
[
'base'
]
=
1000
;
$this
->
assertSame
(
"999 B"
,
$this
->
formatter
->
asSize
(
999
));
$this
->
assertSame
(
"1.05 MB"
,
$this
->
formatter
->
asSize
(
1024
*
1024
));
$this
->
assertSame
(
"1.05 MB"
,
$this
->
formatter
->
asSize
(
1024
*
1024
,
false
,
false
));
$this
->
assertSame
(
"1 KB"
,
$this
->
formatter
->
asSize
(
1000
));
$this
->
assertSame
(
"1.02 KB"
,
$this
->
formatter
->
asSize
(
1023
));
$this
->
assertSame
(
"3 gigabytes"
,
$this
->
formatter
->
asSize
(
3
*
1000
*
1000
*
1000
,
true
));
$this
->
assertNotSame
(
"3 PB"
,
$this
->
formatter
->
asSize
(
3
*
1000
*
1000
*
1000
*
1000
*
1000
*
1000
));
// this is 3 EB not 3 PB
// tests for base 1024
$this
->
formatter
->
sizeFormat
[
'base'
]
=
1024
;
...
...
@@ -205,6 +207,8 @@ class FormatterTest extends TestCase
$this
->
assertSame
(
"1 MB"
,
$this
->
formatter
->
asSize
(
1024
*
1024
,
false
,
false
));
$this
->
assertSame
(
"1023 B"
,
$this
->
formatter
->
asSize
(
1023
));
$this
->
assertSame
(
"5 GiB"
,
$this
->
formatter
->
asSize
(
5
*
1024
*
1024
*
1024
));
$this
->
assertSame
(
"5 gibibytes"
,
$this
->
formatter
->
asSize
(
5
*
1024
*
1024
*
1024
,
true
));
$this
->
assertNotSame
(
"5 PiB"
,
$this
->
formatter
->
asSize
(
5
*
1024
*
1024
*
1024
*
1024
*
1024
*
1024
));
// this is 5 EiB not 5 PiB
//$this->assertSame("1 YiB", $this->formatter->asSize(pow(2, 80)));
$this
->
assertSame
(
"2 GiB"
,
$this
->
formatter
->
asSize
(
2147483647
));
// round 1.999 up to 2
$this
->
formatter
->
sizeFormat
[
'decimalSeparator'
]
=
','
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment