From 62e7c3e9a6bc700da00c2a4e7b3d175169c04592 Mon Sep 17 00:00:00 2001 From: Carsten Brandt <mail@cebe.cc> Date: Fri, 15 Aug 2014 15:30:32 +0200 Subject: [PATCH] fixed some inconsistnecies in HHVM tests exclude parts that have different default values --- framework/i18n/Formatter.php | 10 +++++----- tests/unit/framework/base/FormatterTest.php | 10 ++++++++-- tests/unit/framework/i18n/FormatterTest.php | 12 +++++++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/framework/i18n/Formatter.php b/framework/i18n/Formatter.php index 592c755..96f7ad7 100644 --- a/framework/i18n/Formatter.php +++ b/framework/i18n/Formatter.php @@ -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) diff --git a/tests/unit/framework/base/FormatterTest.php b/tests/unit/framework/base/FormatterTest.php index 1643b8e..02090e8 100644 --- a/tests/unit/framework/base/FormatterTest.php +++ b/tests/unit/framework/base/FormatterTest.php @@ -265,7 +265,10 @@ class FormatterTest extends TestCase $this->assertSame('12 years ago', $this->formatter->asRelativeTime($interval_12_years)); // Pass a DateInterval string - $this->assertSame('a year ago', $this->formatter->asRelativeTime('2007-03-01T13:00:00Z/2008-05-11T15:30:00Z')); + 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 - $this->assertSame('in a year', $this->formatter->asRelativeTime('2008-05-11T15:30:00Z/2007-03-01T13:00:00Z')); + 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'); diff --git a/tests/unit/framework/i18n/FormatterTest.php b/tests/unit/framework/i18n/FormatterTest.php index f457cbc..580b86a 100644 --- a/tests/unit/framework/i18n/FormatterTest.php +++ b/tests/unit/framework/i18n/FormatterTest.php @@ -47,12 +47,19 @@ class FormatterTest extends TestCase $value = '123456'; $this->assertSame("123,456", $this->formatter->asDecimal($value)); $value = '-123456.123'; - $this->assertSame("-123,456.123", $this->formatter->asDecimal($value)); + 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'; -- libgit2 0.27.1