8000 minor #9479 [Locale] fixed the failing test described in #9455 (andre… · symfony/symfony@74201e0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 74201e0

Browse files
committed
minor #9479 [Local 10000 e] fixed the failing test described in #9455 (andremaha)
This PR was merged into the 2.2 branch. Discussion ---------- [Locale] fixed the failing test described in #9455 | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9455 | License | MIT | Doc PR | - Commits ------- 3f91039 [Locale] fixed the failing test described in #9455
2 parents 16b01ec + 3f91039 commit 74201e0

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/Symfony/Component/Locale/Tests/Stub/StubIntlDateFormatterTest.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -503,18 +503,18 @@ public function testFormatWithGmtTimezoneIntl()
503503
$this->assertEquals('GMT+03:00', $formatter->format(0));
504504
}
505505

506-
public function testFormatWithDefaultTimezoneStub()
506+
public function testFormatWithConstructorTimezoneStub()
507507
{
508-
$formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
508+
$formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT, 'UTC');
509509
$formatter->setPattern('yyyy-MM-dd HH:mm:ss');
510510

511511
$this->assertEquals(
512-
$this->createDateTime(0)->format('Y-m-d H:i:s'),
512+
$this->createDateTime(0, 'UTC')->format('Y-m-d H:i:s'),
513513
$formatter->format(0)
514514
);
515515
}
516516

517-
public function testFormatWithDefaultTimezoneIntl()
517+
public function testFormatWithConstructorTimezoneIntl()
518518
{
519519
$this->skipIfIntlExtensionIsNotLoaded();
520520
$this->skipIfICUVersionIsTooOld();
@@ -523,7 +523,7 @@ public function testFormatWithDefaultTimezoneIntl()
523523
$formatter->setPattern('yyyy-MM-dd HH:mm:ss');
524524

525525
$this->assertEquals(
526-
$this->createDateTime(0)->format('Y-m-d H:i:s'),
526+
$this->createDateTime(0, 'UTC')->format('Y-m-d H:i:s'),
527527
$formatter->format(0)
528528
);
529529
}
@@ -541,7 +541,7 @@ public function testFormatWithDefaultTimezoneStubShouldUseTheTzEnvironmentVariab
541541
$formatter->setPattern('yyyy-MM-dd HH:mm:ss');
542542

543543
$this->assertEquals(
544-
$this->createDateTime(0)->format('Y-m-d H:i:s'),
544+
$this->createDateTime(0, 'Europe/London')->format('Y-m-d H:i:s'),
545545
$formatter->format(0)
546546
);
547547

@@ -564,7 +564,7 @@ public function testFormatWithDefaultTimezoneStubShouldUseDefaultDateTimeZoneVar
564564
$formatter->setPattern('yyyy-MM-dd HH:mm:ss');
565565

566566
$this->assertEquals(
567-
$this->createDateTime(0)->format('Y-m-d H:i:s'),
567+
$this->createDateTime(0, 'Europe/London')->format('Y-m-d H:i:s'),
568568
$formatter->format(0)
569569
);
570570

@@ -599,7 +599,7 @@ public function testFormatWithDefaultTimezoneIntlShouldUseTheTzEnvironmentVariab
599599
$this->assertEquals('Europe/Paris', getenv('TZ'));
600600

601601
$this->assertEquals(
602-
$this->createDateTime(0)->format('Y-m-d H:i:s'),
602+
$this->createDateTime(0, 'Europe/Paris')->format('Y-m-d H:i:s'),
603603
$formatter->format(0)
604604
);
605605

@@ -628,7 +628,7 @@ public function testFormatWithDefaultTimezoneIntlShouldUseDefaultDateTimeZoneVar
628628
$this->assertEquals('Europe/Paris', date_default_timezone_get());
629629

630630
$this->assertEquals(
631-
$this->createDateTime(0)->format('Y-m-d H:i:s'),
631+
$this->createDateTime(0, 'Europe/Paris')->format('Y-m-d H:i:s'),
632632
$formatter->format(0)
633633
);
634634

@@ -1223,13 +1223,8 @@ protected function createIntlFormatter($pattern = null)
12231223
return new \IntlDateFormatter('en', \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT, 'UTC', \IntlDateFormatter::GREGORIAN, $pattern);
12241224
}
12251225

1226-
protected function createDateTime($timestamp = null)
1226+
protected function createDateTime($timestamp, $timeZone)
12271227
{
1228-
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
1229-
$timeZone = date_default_timezone_get();
1230-
} else {
1231-
$timeZone = getenv('TZ') ?: 'UTC';
1232-
}
12331228

12341229
$dateTime = new \DateTime();
12351230
$dateTime->setTimestamp(null === $timestamp ? time() : $timestamp);

0 commit comments

Comments
 (0)
0