8000 [Intl] Fix tests by nicolas-grekas · Pull Request #48952 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Intl] Fix tests #48952

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
Jan 11, 2023
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 @@ -35,10 +35,18 @@ public function format(\DateTime $dateTime, int $length): string
return $this->padLeft($quarter, $length);
case 3:
return 'Q'.$quarter;
default:
case 4:
$map = [1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter'];

return $map[$quarter];
default:
if (\defined('INTL_ICU_VERSION') && version_compare(\INTL_ICU_VERSION, '70.1', '<')) {
$map = [1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter'];

return $map[$quarter];
} else {
return $quarter;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ public function formatProvider()
$dateTime = new \DateTime('@0');
$dateTimeImmutable = new \DateTimeImmutable('@0');

/* https://unicode-org.atlassian.net/browse/ICU-21647 */
$expectedQuarterX5 = '1';
if (\defined('INTL_ICU_VERSION') && version_compare(\INTL_ICU_VERSION, '70.1', '<')) {
$expectedQuarterX5 = '1st quarter';
}

$formatData = [
/* general */
['y-M-d', 0, '1970-1-1'],
Expand Down Expand Up @@ -144,13 +150,13 @@ public function formatProvider()
['QQ', 0, '01'],
['QQQ', 0, 'Q1'],
['QQQQ', 0, '1st quarter'],
['QQQQQ', 0, '1st quarter'],
['QQQQQ', 0, $expectedQuarterX5],

['q', 0, '1'],
['qq', 0, '01'],
['qqq', 0, 'Q1'],
['qqqq', 0, '1st quarter'],
['qqqqq', 0, '1st quarter'],
['qqqqq', 0, $expectedQuarterX5],

// 4 months
['Q', 7776000, '2'],
Expand Down Expand Up @@ -363,6 +369,10 @@ public function formatWithTimezoneProvider()
*/
public function testFormatTimezone($pattern, $timezone, $expected)
{
if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && str_contains($timezone, 'GMT')) {
$this->markTestSkipped('Broken version of PHP');
}

$formatter = $this->getDefaultDateFormatter($pattern);
$formatter->setTimeZone(new \DateTimeZone($timezone));

Expand Down Expand Up @@ -421,6 +431,10 @@ public function formatTimezoneProvider()

public function testFormatWithGmtTimezone()
{
if (80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) {
$this->markTestSkipped('Broken version of PHP');
}

$formatter = $this->getDefaultDateFormatter('zzzz');

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

public function testFormatWithGmtTimeZoneAndMinutesOffset()
{
if (80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) {
$this->markTestSkipped('Broken version of PHP');
}

$formatter = $this->getDefaultDateFormatter('zzzz');

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

public function parseTimezoneProvider()
{
if (80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) {
return [['y-M-d HH:mm:ss', '1970-1-1 00:00:00', 0]];
}

return [
['y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-03:00', 10800],
['y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-04:00', 14400],
Expand Down Expand Up @@ -912,6 +934,10 @@ public function testSetPattern()
*/
public function testSetTimeZoneId($timeZoneId, $expectedTimeZoneId)
{
if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && str_contains($timeZoneId ?? '', 'GMT')) {
$this->markTestSkipped('Broken version of PHP');
}

$formatter = $this->getDefaultDateFormatter();

$formatter->setTimeZone($timeZoneId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ public function testParseThreeDigitsYears()

protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
{
if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && \is_string($timezone) && str_contains($timezone, 'GMT')) {
$this->markTestSkipped('Broken version of PHP');
}

return new class($locale, $datetype, $timetype, $timezone, $calendar, $pattern) extends IntlDateFormatter {
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ protected function setUp(): void
*/
public function testFormatTimezone($pattern, $timezone, $expected)
{
if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && str_contains($timezone, 'GMT')) {
$this->markTestSkipped('Broken version of PHP');
}

IntlTestHelper::requireFullIntl($this, '59.1');

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

protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
{
if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && \is_string($timezone) && str_contains($timezone, 'GMT')) {
$this->markTestSkipped('Broken version of PHP');
}

IntlTestHelper::requireFullIntl($this, '55.1');

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