[Intl] Fix test

This commit is contained in:
Nicolas Grekas 2015-09-02 17:00:49 +02:00
parent fedbf711a1
commit 79695037b0
3 changed files with 14 additions and 7 deletions

View File

@ -29,7 +29,7 @@ class TimeZoneTransformer extends Transformer
{ {
$timeZone = substr($dateTime->getTimezone()->getName(), 0, 3); $timeZone = substr($dateTime->getTimezone()->getName(), 0, 3);
if (!in_array($timeZone, array('Etc', 'UTC'))) { if (!in_array($timeZone, array('Etc', 'UTC', 'GMT'))) {
throw new NotImplementedException('Time zone different than GMT or UTC is not supported as a formatting output.'); throw new NotImplementedException('Time zone different than GMT or UTC is not supported as a formatting output.');
} }

View File

@ -773,7 +773,7 @@ class NumberFormatter
* @param mixed $value The value to be converted * @param mixed $value The value to be converted
* @param int $type The type to convert. Can be TYPE_DOUBLE (float) or TYPE_INT32 (int) * @param int $type The type to convert. Can be TYPE_DOUBLE (float) or TYPE_INT32 (int)
* *
* @return int|float The converted value * @return int|float|false The converted value
*/ */
private function convertValueDataType($value, $type) private function convertValueDataType($value, $type)
{ {
@ -793,7 +793,7 @@ class NumberFormatter
* *
* @param mixed $value The value to be converted * @param mixed $value The value to be converted
* *
* @return int The converted value * @return int|false The converted value
*/ */
private function getInt32Value($value) private function getInt32Value($value)
{ {
@ -809,7 +809,7 @@ class NumberFormatter
* *
* @param mixed $value The value to be converted * @param mixed $value The value to be converted
* *
* @return int|float The converted value * @return int|float|false The converted value
* *
* @see https://bugs.php.net/bug.php?id=59597 Bug #59597 * @see https://bugs.php.net/bug.php?id=59597 Bug #59597
*/ */

View File

@ -392,14 +392,21 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
); );
} }
public function testFormatWithDateTimeZone() public function testFormatWithDateTimeZoneGmt()
{ {
if (PHP_VERSION_ID < 50500) { if (PHP_VERSION_ID < 50500) {
$this->markTestSkipped('Only in PHP 5.5+ IntlDateFormatter allows to use DateTimeZone objects.'); $this->markTestSkipped('Only in PHP 5.5+ IntlDateFormatter allows to use DateTimeZone objects.');
} }
if (defined('HHVM_VERSION_ID')) { $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, new \DateTimeZone('GMT'), IntlDateFormatter::GREGORIAN, 'zzzz');
$this->markTestSkipped('This test cannot work on HHVM. See https://github.com/facebook/hhvm/issues/5875 for the issue.');
$this->assertEquals('GMT', $formatter->format(0));
}
public function testFormatWithDateTimeZoneGmtOffset()
{
if (defined('HHVM_VERSION_ID') || PHP_VERSION_ID <= 50509) {
$this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.');
} }
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, new \DateTimeZone('GMT+03:00'), IntlDateFormatter::GREGORIAN, 'zzzz'); $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, new \DateTimeZone('GMT+03:00'), IntlDateFormatter::GREGORIAN, 'zzzz');