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
2fbce2fa
Commit
2fbce2fa
authored
Sep 30, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved formatter test coverage
parent
2dddd0e8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
FormatterTest.php
tests/unit/framework/i18n/FormatterTest.php
+11
-3
No files found.
tests/unit/framework/i18n/FormatterTest.php
View file @
2fbce2fa
...
...
@@ -852,6 +852,7 @@ class FormatterTest extends TestCase
// tests for base 1000
$this
->
formatter
->
sizeFormatBase
=
1000
;
$this
->
assertSame
(
"999 B"
,
$this
->
formatter
->
asShortSize
(
999
));
$this
->
assertSame
(
"999 B"
,
$this
->
formatter
->
asShortSize
(
'999'
));
$this
->
assertSame
(
"1.05 MB"
,
$this
->
formatter
->
asShortSize
(
1024
*
1024
));
$this
->
assertSame
(
"1 KB"
,
$this
->
formatter
->
asShortSize
(
1000
));
$this
->
assertSame
(
"1.02 KB"
,
$this
->
formatter
->
asShortSize
(
1023
));
...
...
@@ -874,7 +875,7 @@ class FormatterTest extends TestCase
$this
->
assertSame
(
'0 B'
,
$this
->
formatter
->
asShortSize
(
0
));
// null display
$this
->
assertSame
(
$this
->
formatter
->
nullDisplay
,
$this
->
formatter
->
asSize
(
null
));
$this
->
assertSame
(
$this
->
formatter
->
nullDisplay
,
$this
->
formatter
->
asS
hortS
ize
(
null
));
}
public
function
testAsShortSize
()
...
...
@@ -882,6 +883,7 @@ class FormatterTest extends TestCase
// tests for base 1000
$this
->
formatter
->
sizeFormatBase
=
1000
;
$this
->
assertSame
(
"999 B"
,
$this
->
formatter
->
asShortSize
(
999
));
$this
->
assertSame
(
"999 B"
,
$this
->
formatter
->
asShortSize
(
'999'
));
$this
->
assertSame
(
"1.05 MB"
,
$this
->
formatter
->
asShortSize
(
1024
*
1024
));
$this
->
assertSame
(
"1.0486 MB"
,
$this
->
formatter
->
asShortSize
(
1024
*
1024
,
4
));
$this
->
assertSame
(
"1.00 KB"
,
$this
->
formatter
->
asShortSize
(
1000
));
...
...
@@ -901,10 +903,10 @@ class FormatterTest extends TestCase
$this
->
assertSame
(
"1,001 KiB"
,
$this
->
formatter
->
asShortSize
(
1025
,
3
));
// empty values
$this
->
assertSame
(
'0
bytes'
,
$this
->
formatter
->
as
Size
(
0
));
$this
->
assertSame
(
'0
B'
,
$this
->
formatter
->
asShort
Size
(
0
));
// null display
$this
->
assertSame
(
$this
->
formatter
->
nullDisplay
,
$this
->
formatter
->
asSize
(
null
));
$this
->
assertSame
(
$this
->
formatter
->
nullDisplay
,
$this
->
formatter
->
asS
hortS
ize
(
null
));
}
public
function
testIntlAsSize
()
...
...
@@ -917,6 +919,7 @@ class FormatterTest extends TestCase
// tests for base 1000
$this
->
formatter
->
sizeFormatBase
=
1000
;
$this
->
assertSame
(
"999 bytes"
,
$this
->
formatter
->
asSize
(
999
));
$this
->
assertSame
(
"999 bytes"
,
$this
->
formatter
->
asSize
(
'999'
));
$this
->
assertSame
(
"1.05 megabytes"
,
$this
->
formatter
->
asSize
(
1024
*
1024
));
$this
->
assertSame
(
"1 kilobyte"
,
$this
->
formatter
->
asSize
(
1000
));
$this
->
assertSame
(
"1.02 kilobytes"
,
$this
->
formatter
->
asSize
(
1023
));
...
...
@@ -943,6 +946,7 @@ class FormatterTest extends TestCase
// tests for base 1000
$this
->
formatter
->
sizeFormatBase
=
1000
;
$this
->
assertSame
(
"999 bytes"
,
$this
->
formatter
->
asSize
(
999
));
$this
->
assertSame
(
"999 bytes"
,
$this
->
formatter
->
asSize
(
'999'
));
$this
->
assertSame
(
"1.05 megabytes"
,
$this
->
formatter
->
asSize
(
1024
*
1024
));
$this
->
assertSame
(
"1.0486 megabytes"
,
$this
->
formatter
->
asSize
(
1024
*
1024
,
4
));
$this
->
assertSame
(
"1.00 kilobyte"
,
$this
->
formatter
->
asSize
(
1000
));
...
...
@@ -968,8 +972,10 @@ class FormatterTest extends TestCase
public
function
testIntlAsSizeConfiguration
()
{
$this
->
assertSame
(
"1023 bytes"
,
$this
->
formatter
->
asSize
(
1023
));
$this
->
assertSame
(
"1023 B"
,
$this
->
formatter
->
asShortSize
(
1023
));
$this
->
formatter
->
thousandSeparator
=
'.'
;
$this
->
assertSame
(
"1023 bytes"
,
$this
->
formatter
->
asSize
(
1023
));
$this
->
assertSame
(
"1023 B"
,
$this
->
formatter
->
asShortSize
(
1023
));
}
/**
...
...
@@ -978,7 +984,9 @@ class FormatterTest extends TestCase
public
function
testAsSizeConfiguration
()
{
$this
->
assertSame
(
"1023 bytes"
,
$this
->
formatter
->
asSize
(
1023
));
$this
->
assertSame
(
"1023 B"
,
$this
->
formatter
->
asShortSize
(
1023
));
$this
->
formatter
->
thousandSeparator
=
'.'
;
$this
->
assertSame
(
"1023 bytes"
,
$this
->
formatter
->
asSize
(
1023
));
$this
->
assertSame
(
"1023 B"
,
$this
->
formatter
->
asShortSize
(
1023
));
}
}
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