Skip to content

Commit a9e7b90

Browse files
committedJan 9, 2023
Adapt ext/intl tests for ICU 72.1
This version replaces SPACEs before the meridian with NARROW NO-BREAK SPACEs. Thus, we split the affected test cases as usual. (cherry picked from commit 8dd51b4) Fixes GH-10262.
1 parent 4d4a53b commit a9e7b90

20 files changed

+681
-0
lines changed
 

‎ext/intl/tests/dateformat_calendars_variant3.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ date.timezone=Atlantic/Azores
66
intl
77
--SKIPIF--
88
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
9+
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
910
--FILE--
1011
<?php
1112
ini_set("intl.error_level", E_WARNING);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
--TEST--
2+
IntlDateFormatter, calendars and time zone
3+
--INI--
4+
date.timezone=Atlantic/Azores
5+
--EXTENSIONS--
6+
intl
7+
--SKIPIF--
8+
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
9+
--FILE--
10+
<?php
11+
ini_set("intl.error_level", E_WARNING);
12+
13+
$fmt1 = new IntlDateFormatter('en_US',
14+
IntlDateFormatter::FULL,
15+
IntlDateFormatter::FULL,
16+
'GMT+05:12',
17+
IntlDateFormatter::TRADITIONAL);
18+
$fmt2 = new IntlDateFormatter('en_US',
19+
IntlDateFormatter::FULL,
20+
IntlDateFormatter::FULL,
21+
'GMT+05:12',
22+
IntlDateFormatter::GREGORIAN);
23+
$fmt3 = new IntlDateFormatter('en_US@calendar=hebrew',
24+
IntlDateFormatter::FULL,
25+
IntlDateFormatter::FULL,
26+
'GMT+05:12',
27+
IntlDateFormatter::TRADITIONAL);
28+
var_dump($fmt1->format(strtotime('2012-01-01 00:00:00 +0000')));
29+
var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000')));
30+
var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000')));
31+
32+
new IntlDateFormatter('en_US@calendar=hebrew',
33+
IntlDateFormatter::FULL,
34+
IntlDateFormatter::FULL,
35+
'GMT+05:12',
36+
-1);
37+
?>
38+
==DONE==
39+
--EXPECTF--
40+
string(49) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
41+
string(49) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
42+
string(46) "Sunday, 6 Tevet 5772 at 5:12:00 AM GMT+05:12"
43+
44+
Fatal error: Uncaught IntlException: IntlDateFormatter::__construct(): datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s:%d
45+
Stack trace:
46+
#0 %s(%d): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1)
47+
#1 {main}
48+
thrown in %s on line %d

‎ext/intl/tests/dateformat_create_default.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ IntlDateFormatter::create() with default date and time types
44
intl
55
--INI--
66
date.timezone=UTC
7+
--SKIPIF--
8+
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
79
--FILE--
810
<?php
911

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
IntlDateFormatter::create() with default date and time types
3+
--EXTENSIONS--
4+
intl
5+
--INI--
6+
date.timezone=UTC
7+
--SKIPIF--
8+
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
9+
--FILE--
10+
<?php
11+
12+
$ts = strtotime('2012-01-01 00:00:00 UTC');
13+
$fmt = IntlDateFormatter::create('en_US');
14+
echo $fmt->format($ts), "\n";
15+
16+
$fmt = new IntlDateFormatter('en_US');
17+
echo $fmt->format($ts), "\n";
18+
19+
$fmt = datefmt_create('en_US');
20+
echo $fmt->format($ts), "\n";
21+
22+
?>
23+
--EXPECT--
24+
Sunday, January 1, 2012 at 12:00:00 AM Coordinated Universal Time
25+
Sunday, January 1, 2012 at 12:00:00 AM Coordinated Universal Time
26+
Sunday, January 1, 2012 at 12:00:00 AM Coordinated Universal Time

‎ext/intl/tests/dateformat_formatObject_calendar_variant5.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ IntlDateFormatter::formatObject(): IntlCalendar tests
44
intl
55
--SKIPIF--
66
<?php if (version_compare(INTL_ICU_VERSION, '55.1') < 0) die('skip for ICU >= 55.1'); ?>
7+
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
78
--FILE--
89
<?php
910
ini_set("intl.error_level", E_WARNING);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
IntlDateFormatter::formatObject(): IntlCalendar tests
3+
--EXTENSIONS--
4+
intl
5+
--SKIPIF--
6+
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
7+
--FILE--
8+
<?php
9+
ini_set("intl.error_level", E_WARNING);
10+
ini_set("intl.default_locale", "pt_PT");
11+
ini_set("date.timezone", "Europe/Lisbon");
12+
13+
$cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00'); //Europe/Lisbon
14+
echo IntlDateFormatter::formatObject($cal), "\n";
15+
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
16+
echo IntlDateFormatter::formatObject($cal, null, "en-US"), "\n";
17+
echo IntlDateFormatter::formatObject($cal, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
18+
echo IntlDateFormatter::formatObject($cal, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
19+
20+
$cal = IntlCalendar::fromDateTime('2012-01-01 05:00:00+03:00');
21+
echo datefmt_format_object($cal, IntlDateFormatter::FULL), "\n";
22+
23+
$cal = IntlCalendar::createInstance(null,'en-US@calendar=islamic-civil');
24+
$cal->setTime(strtotime('2012-01-01 00:00:00')*1000.);
25+
echo IntlDateFormatter::formatObject($cal), "\n";
26+
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n";
27+
28+
?>
29+
--EXPECTF--
30+
01/01/2012, 00:00:00
31+
domingo, 1 de janeiro de 2012 às 00:00:00 Hora padrão %Sda Europa Ocidental
32+
Jan 1, 2012, 12:00:00 AM
33+
1/1/12, 12:00:00 AM Western European Standard Time
34+
Sun 2012-01-1 00,00,00.000 Portugal Time
35+
domingo, 1 de janeiro de 2012 às 05:00:00 GMT+03:00
36+
06/02/1433, 00:00:00
37+
Sunday, Safar 6, 1433 at 12:00:00 AM Western European Standard Time

‎ext/intl/tests/dateformat_formatObject_datetime_variant5.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ IntlDateFormatter::formatObject(): DateTime tests
44
intl
55
--SKIPIF--
66
<?php if (version_compare(INTL_ICU_VERSION, '55.1') < 0) die('skip for ICU >= 55.1'); ?>
7+
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
78
--FILE--
89
<?php
910
ini_set("intl.error_level", E_WARNING);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
IntlDateFormatter::formatObject(): DateTime tests
3+
--EXTENSIONS--
4+
intl
5+
--SKIPIF--
6+
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU < 72.1'); ?>
7+
--FILE--
8+
<?php
9+
ini_set("intl.error_level", E_WARNING);
10+
ini_set("intl.default_locale", "pt_PT");
11+
ini_set("date.timezone", "Europe/Lisbon");
12+
13+
$dt = new DateTime('2012-01-01 00:00:00'); //Europe/Lisbon
14+
echo IntlDateFormatter::formatObject($dt), "\n";
15+
echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
16+
echo IntlDateFormatter::formatObject($dt, null, "en-US"), "\n";
17+
echo IntlDateFormatter::formatObject($dt, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
18+
echo IntlDateFormatter::formatObject($dt, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
19+
20+
$dt = new DateTime('2012-01-01 05:00:00+03:00');
21+
echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
22+
23+
?>
24+
--EXPECTF--
25+
01/01/2012, 00:00:00
26+
domingo, 1 de janeiro de 2012 às 00:00:00 Hora padrão %Sda Europa Ocidental
27+
Jan 1, 2012, 12:00:00 AM
28+
1/1/12, 12:00:00 AM Western European Standard Time
29+
Sun 2012-01-1 00,00,00.000 Portugal Time
30+
domingo, 1 de janeiro de 2012 às 05:00:00 GMT+03:00

‎ext/intl/tests/dateformat_format_parse_version2.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ datefmt_format_code() and datefmt_parse_code()
44
intl
55
--SKIPIF--
66
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
7+
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
78
--FILE--
89
<?php
910

0 commit comments

Comments
 (0)
Please sign in to comment.