Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Intl] Fix test #15672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function format(\DateTime $dateTime, $length)
{
$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.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ private function isInitializedAttribute($attr)
* @param mixed $value The value to be converted
* @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)
{
Expand All @@ -793,7 +793,7 @@ private function convertValueDataType($value, $type)
*
* @param mixed $value The value to be converted
*
* @return int The converted value
* @return int|false The converted value
*/
private function getInt32Value($value)
{
Expand All @@ -809,7 +809,7 @@ private function getInt32Value($value)
*
* @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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,21 @@ public function testFormatWithConstructorTimezone()
);
}

public function testFormatWithDateTimeZone()
public function testFormatWithDateTimeZoneGmt()
{
if (PHP_VERSION_ID < 50500) {
$this->markTestSkipped('Only in PHP 5.5+ IntlDateFormatter allows to use DateTimeZone objects.');
}

if (defined('HHVM_VERSION_ID')) {
$this->markTestSkipped('This test cannot work on HHVM. See https://github.com/facebook/hhvm/issues/5875 for the issue.');
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, new \DateTimeZone('GMT'), IntlDateFormatter::GREGORIAN, 'zzzz');

$this->assertEquals('GMT', $formatter->format(0));
}

public function testFormatWithDateTimeZoneGmtOffset()
{
if (defined('HHVM_VERSION_ID') || PHP_VERSION_ID <= 50509) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the PHP_VERSION_ID check is actually 3 lines above. Just update it with the right version (I thought it was 5.5.0+)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer keeping it this way to easy future merge in master

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and also because the reason message is not the same)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, currently, we have 2 different skipping messages: 1 for PHP saying it needs PHP 5.5.10+ (assuming it gets fixes), and the other one for HHVM linking to the HHVM issue.
It makes more sense to use keep the PHP check in a single place rather than 2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah indeed. For PHP 5.4, we talk about IntlDateFormatter features, not about DateTimeZone limitations. So I agree about keeping like that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I slitted the test in two, one with the GMT offset, an other with GMT

$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');
Expand Down