8000 minor #48952 [Intl] Fix tests (nicolas-grekas) · symfony/symfony@8cf82db · GitHub
[go: up one dir, main page]

Skip to content

Commit 8cf82db

Browse files
minor #48952 [Intl] Fix tests (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [Intl] Fix tests | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - And backport symfony/polyfill#399 Commits ------- af188b0 [Intl] Fix tests
2 parents 22b5860 + af188b0 commit 8cf82db

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

src/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,18 @@ public function format(\DateTime $dateTime, int $length): string
3535
return $this->padLeft($quarter, $length);
3636
case 3:
3737
return 'Q'.$quarter;
38-
default:
38+
case 4:
3939
$map = [1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter'];
4040

4141
return $map[$quarter];
42+
default:
43+
if (\defined('INTL_ICU_VERSION') && version_compare(\INTL_ICU_VERSION, '70.1', '<')) {
44+
$map = [1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter'];
45+
46+
return $map[$quarter];
47+
} else {
48+
return $quarter;
49+
}
4250
}
4351
}
4452

src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ public function formatProvider()
9696
$dateTime = new \DateTime('@0');
9797
$dateTimeImmutable = new \DateTimeImmutable('@0');
9898

99+
/* https://unicode-org.atlassian.net/browse/ICU-21647 */
100+
$expectedQuarterX5 = '1';
101+
if (\defined('INTL_ICU_VERSION') && version_compare(\INTL_ICU_VERSION, '70.1', '<')) {
102+
$expectedQuarterX5 = '1st quarter';
103+
}
104+
99105
$formatData = [
100106
/* general */
101107
['y-M-d', 0, '1970-1-1'],
@@ -144,13 +150,13 @@ public function formatProvider()
144150
['QQ', 0, '01'],
145151
['QQQ', 0, 'Q1'],
146152
['QQQQ', 0, '1st quarter'],
147-
['QQQQQ', 0, '1st quarter'],
153+
['QQQQQ', 0, $expectedQuarterX5],
148154

149155
['q', 0, '1'],
150156
['qq', 0, '01'],
151157
['qqq', 0, 'Q1'],
152158
['qqqq', 0, '1st quarter'],
153-
['qqqqq', 0, '1st quarter'],
159+
['qqqqq', 0, $expectedQuarterX5],
154160

155161
// 4 months
156162
['Q', 7776000, '2'],
@@ -363,6 +369,10 @@ public function formatWithTimezoneProvider()
363369
*/
364370
public function testFormatTimezone($pattern, $timezone, $expected)
365371
{
372+
if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && str_contains($timezone, 'GMT')) {
373+
$this->markTestSkipped('Broken version of PHP');
374+
}
375+
366376
$formatter = $this->getDefaultDateFormatter($pattern);
367377
$formatter->setTimeZone(new \DateTimeZone($timezone));
368378

@@ -421,6 +431,10 @@ public function formatTimezoneProvider()
421431

422432
public function testFormatWithGmtTimezone()
423433
{
434+
if (80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) {
435+
$this->markTestSkipped('Broken version of PHP');
436+
}
437+
424438
$formatter = $this->getDefaultDateFormatter('zzzz');
425439

426440
$formatter->setTimeZone('GMT+03:00');
@@ -430,6 +444,10 @@ public function testFormatWithGmtTimezone()
430444

431445
public function testFormatWithGmtTimeZoneAndMinutesOffset()
432446
{
447+
if (80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) {
448+
$this->markTestSkipped('Broken version of PHP');
449+
}
450+
433451
$formatter = $this->getDefaultDateFormatter('zzzz');
434452

435453
$formatter->setTimeZone('GMT+00:30');
@@ -794,6 +812,10 @@ public function parseSecondProvider()
794812

795813
public function parseTimezoneProvider()
796814
{
815+
if (80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) {
816+
return [['y-M-d HH:mm:ss', '1970-1-1 00:00:00', 0]];
817+
}
818+
797819
return [
798820
['y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-03:00', 10800],
799821
['y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-04:00', 14400],
@@ -912,6 +934,10 @@ public function testSetPattern()
912934
*/
913935
public function testSetTimeZoneId($timeZoneId, $expectedTimeZoneId)
914936
{
937+
if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && str_contains($timeZoneId ?? '', 'GMT')) {
938+
$this->markTestSkipped('Broken version of PHP');
939+
}
940+
915941
$formatter = $this->getDefaultDateFormatter();
916942

917943
$formatter->setTimeZone($timeZoneId);

src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ public function testParseThreeDigitsYears()
186186

187187
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
188188
{
189+
if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && \is_string($timezone) && str_contains($timezone, 'GMT')) {
190+
$this->markTestSkipped('Broken version of PHP');
191+
}
192+
189193
return new class($locale, $datetype, $timetype, $timezone, $calendar, $pattern) extends IntlDateFormatter {
190194
};
191195
}

src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ protected function setUp(): void
3535
*/
3636
public function testFormatTimezone($pattern, $timezone, $expected)
3737
{
38+
if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && str_contains($timezone, 'GMT')) {
39+
$this->markTestSkipped('Broken version of PHP');
40+
}
41+
3842
IntlTestHelper::requireFullIntl($this, '59.1');
3943

4044
parent::testFormatTimezone($pattern, $timezone, $expected);
@@ -59,6 +63,10 @@ public function testDateAndTimeType($timestamp, $datetype, $timetype, $expected)
5963

6064
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
6165
{
66+
if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && \is_string($timezone) && str_contains($timezone, 'GMT')) {
67+
$this->markTestSkipped('Broken version of PHP');
68+
}
69+
6270
IntlTestHelper::requireFullIntl($this, '55.1');
6371

6472
if (!$formatter = new \IntlDateFormatter($locale, $datetype ?? IntlDateFormatter::FULL, $timetype ?? IntlDateFormatter::FULL, $timezone, $calendar, $pattern)) {

0 commit comments

Comments
 (0)
0