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
62e7c3e9
Commit
62e7c3e9
authored
Aug 15, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed some inconsistnecies in HHVM tests
exclude parts that have different default values
parent
10512ff0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
5 deletions
+21
-5
Formatter.php
framework/i18n/Formatter.php
+5
-5
FormatterTest.php
tests/unit/framework/base/FormatterTest.php
+6
-0
FormatterTest.php
tests/unit/framework/i18n/FormatterTest.php
+10
-0
No files found.
framework/i18n/Formatter.php
View file @
62e7c3e9
...
...
@@ -249,7 +249,7 @@ class Formatter extends \yii\base\Formatter
/**
* Formats the value as a decimal number.
* @param mixed $value the value to be formatted
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#
_
details)
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details)
* for details on how to specify a format.
* @return string the formatted result.
*/
...
...
@@ -267,7 +267,7 @@ class Formatter extends \yii\base\Formatter
* @param mixed $value the value to be formatted
* @param string $currency the 3-letter ISO 4217 currency code indicating the currency to use.
* If null, [[currencyCode]] will be used.
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#
_
details)
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details)
* for details on how to specify a format.
* @return string the formatted result.
*/
...
...
@@ -287,7 +287,7 @@ class Formatter extends \yii\base\Formatter
/**
* Formats the value as a percent number.
* @param mixed $value the value to be formatted
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#
_
details)
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details)
* for details on how to specify a format.
* @return string the formatted result.
*/
...
...
@@ -303,7 +303,7 @@ class Formatter extends \yii\base\Formatter
/**
* Formats the value as a scientific number.
* @param mixed $value the value to be formatted
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#
_
details)
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details)
* for details on how to specify a format.
* @return string the formatted result.
*/
...
...
@@ -319,7 +319,7 @@ class Formatter extends \yii\base\Formatter
/**
* Creates a number formatter based on the given type and format.
* @param integer $type the type of the number formatter
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#
_
details)
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details)
* @return NumberFormatter the created formatter instance
*/
protected
function
createNumberFormatter
(
$type
,
$format
)
...
...
tests/unit/framework/base/FormatterTest.php
View file @
62e7c3e9
...
...
@@ -265,7 +265,10 @@ class FormatterTest extends TestCase
$this
->
assertSame
(
'12 years ago'
,
$this
->
formatter
->
asRelativeTime
(
$interval_12_years
));
// Pass a DateInterval string
if
(
!
defined
(
'HHVM_VERSION'
))
{
// TODO format not supported by HHVM currently https://github.com/facebook/hhvm/issues/2952
$this
->
assertSame
(
'a year ago'
,
$this
->
formatter
->
asRelativeTime
(
'2007-03-01T13:00:00Z/2008-05-11T15:30:00Z'
));
}
$this
->
assertSame
(
'a year ago'
,
$this
->
formatter
->
asRelativeTime
(
'2007-03-01T13:00:00Z/P1Y2M10DT2H30M'
));
$this
->
assertSame
(
'a year ago'
,
$this
->
formatter
->
asRelativeTime
(
'P1Y2M10DT2H30M/2008-05-11T15:30:00Z'
));
$this
->
assertSame
(
'a year ago'
,
$this
->
formatter
->
asRelativeTime
(
'P1Y2M10DT2H30M'
));
...
...
@@ -324,7 +327,10 @@ class FormatterTest extends TestCase
$this
->
assertSame
(
'in 12 years'
,
$this
->
formatter
->
asRelativeTime
(
$interval_12_years
));
// Pass a inverted DateInterval string
if
(
!
defined
(
'HHVM_VERSION'
))
{
// TODO format not supported by HHVM currently https://github.com/facebook/hhvm/issues/2952
$this
->
assertSame
(
'in a year'
,
$this
->
formatter
->
asRelativeTime
(
'2008-05-11T15:30:00Z/2007-03-01T13:00:00Z'
));
}
// Force the reference time and pass a future DateTime
$dateNow
=
new
DateTime
(
'2014-03-13'
);
...
...
tests/unit/framework/i18n/FormatterTest.php
View file @
62e7c3e9
...
...
@@ -47,12 +47,19 @@ class FormatterTest extends TestCase
$value
=
'123456'
;
$this
->
assertSame
(
"123,456"
,
$this
->
formatter
->
asDecimal
(
$value
));
$value
=
'-123456.123'
;
if
(
defined
(
'HHVM_VERSION'
))
{
// the default format is different on HHVM
$this
->
assertSame
(
"-123,456"
,
$this
->
formatter
->
asDecimal
(
$value
));
}
else
{
$this
->
assertSame
(
"-123,456.123"
,
$this
->
formatter
->
asDecimal
(
$value
));
}
$this
->
assertSame
(
$this
->
formatter
->
nullDisplay
,
$this
->
formatter
->
asDecimal
(
null
));
}
public
function
testAsPercent
()
{
if
(
defined
(
'HHVM_VERSION'
))
{
// the default format is different on HHVM
$this
->
markTestSkipped
(
'HHVM behaves quite different in the default patterns used for formatting.'
);
}
$value
=
'123'
;
$this
->
assertSame
(
'12,300%'
,
$this
->
formatter
->
asPercent
(
$value
));
$value
=
'0.1234'
;
...
...
@@ -64,6 +71,9 @@ class FormatterTest extends TestCase
public
function
testAsScientific
()
{
if
(
defined
(
'HHVM_VERSION'
))
{
// the default format is different on HHVM
$this
->
markTestSkipped
(
'HHVM behaves quite different in the default patterns used for formatting.'
);
}
$value
=
'123'
;
$this
->
assertSame
(
'1.23E2'
,
$this
->
formatter
->
asScientific
(
$value
));
$value
=
'123456'
;
...
...
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