Skip to content

Commit 103995b

Browse files
committed
Fix bug #61448 intl tests fail with icu >= 4.8
1 parent 0b20329 commit 103995b

38 files changed

+2931
-26
lines changed

ext/intl/tests/collator_create.phpt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--TEST--
2-
create()
2+
create() icu <= 4.2
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
56
--FILE--
67
<?php
78

ext/intl/tests/collator_create2.phpt

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
--TEST--
2+
create() icu >= 4.8
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
6+
--FILE--
7+
<?php
8+
9+
/*
10+
* Try creating collator with different locales
11+
* with Procedural and Object methods.
12+
*/
13+
14+
function ut_main()
15+
{
16+
$res_str = '';
17+
18+
$locales = array(
19+
'EN-US-ODESSA',
20+
'UK_UA_ODESSA',
21+
'uk-ua_CALIFORNIA@currency=;currency=GRN',
22+
'',
23+
'root',
24+
'uk@currency=EURO',
25+
'1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799'
26+
);
27+
28+
foreach( $locales as $locale )
29+
{
30+
// Create Collator with the current locale.
31+
$coll = ut_coll_create( $locale );
32+
if( !is_object($coll) )
33+
{
34+
$res_str .= "Error creating collator with '$locale' locale: " .
35+
intl_get_error_message() . "\n";
36+
continue;
37+
}
38+
39+
// Get the requested, valid and actual locales.
40+
$vloc = ut_coll_get_locale( $coll, Locale::VALID_LOCALE );
41+
$aloc = ut_coll_get_locale( $coll, Locale::ACTUAL_LOCALE );
42+
43+
// Show them.
44+
$res_str .= "Locale: '$locale'\n" .
45+
" ULOC_REQUESTED_LOCALE = '$locale'\n" .
46+
" ULOC_VALID_LOCALE = '$vloc'\n" .
47+
" ULOC_ACTUAL_LOCALE = '$aloc'\n";
48+
}
49+
50+
return $res_str;
51+
}
52+
53+
include_once( 'ut_common.inc' );
54+
ut_run();
55+
56+
?>
57+
--EXPECTF--
58+
Locale: 'EN-US-ODESSA'
59+
ULOC_REQUESTED_LOCALE = 'EN-US-ODESSA'
60+
ULOC_VALID_LOCALE = 'en_US'
61+
ULOC_ACTUAL_LOCALE = 'root'
62+
Locale: 'UK_UA_ODESSA'
63+
ULOC_REQUESTED_LOCALE = 'UK_UA_ODESSA'
64+
ULOC_VALID_LOCALE = 'uk_UA'
65+
ULOC_ACTUAL_LOCALE = 'uk'
66+
Locale: 'uk-ua_CALIFORNIA@currency=;currency=GRN'
67+
ULOC_REQUESTED_LOCALE = 'uk-ua_CALIFORNIA@currency=;currency=GRN'
68+
ULOC_VALID_LOCALE = 'uk_UA'
69+
ULOC_ACTUAL_LOCALE = 'uk'
70+
Locale: ''
71+
ULOC_REQUESTED_LOCALE = ''
72+
ULOC_VALID_LOCALE = '%s'
73+
ULOC_ACTUAL_LOCALE = '%s'
74+
Locale: 'root'
75+
ULOC_REQUESTED_LOCALE = 'root'
76+
ULOC_VALID_LOCALE = 'root'
77+
ULOC_ACTUAL_LOCALE = 'root'
78+
Locale: 'uk@currency=EURO'
79+
ULOC_REQUESTED_LOCALE = 'uk@currency=EURO'
80+
ULOC_VALID_LOCALE = 'uk'
81+
ULOC_ACTUAL_LOCALE = 'uk'
82+
Error creating collator with '1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' locale: Locale string too long, should be no longer than 80 characters: U_ILLEGAL_ARGUMENT_ERROR

ext/intl/tests/collator_get_locale.phpt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--TEST--
2-
get_locale()
2+
get_locale() icu <= 4.2
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
56
--FILE--
67
<?php
78

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--TEST--
2+
get_locale() icu >= 4.8
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
6+
--FILE--
7+
<?php
8+
9+
/*
10+
* Try to specify valid and invalid locale types when getting locale.
11+
*/
12+
13+
function ut_main()
14+
{
15+
$locales = array(
16+
Locale::VALID_LOCALE,
17+
Locale::ACTUAL_LOCALE,
18+
100,
19+
-100,
20+
-9999999999999,
21+
9999999999999,
22+
1.2,
23+
);
24+
25+
$coll = ut_coll_create( 'en_US' );
26+
$res_str = '';
27+
28+
foreach( $locales as $locale )
29+
{
30+
$rc = ut_coll_get_locale( $coll, $locale );
31+
32+
$res_str .= sprintf(
33+
"Locale of type %s is %s\n",
34+
dump( $locale ),
35+
dump( $rc ) );
36+
}
37+
38+
return $res_str . "\n";
39+
}
40+
41+
include_once( 'ut_common.inc' );
42+
ut_run();
43+
?>
44+
--EXPECT--
45+
Locale of type 1 is 'en_US'
46+
Locale of type 0 is 'root'
47+
Locale of type 100 is false
48+
Locale of type -100 is false
49+
Locale of type -9999999999999 is false
50+
Locale of type 9999999999999 is false
51+
Locale of type 1.2 is 'en_US'

ext/intl/tests/dateformat_clone.phpt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--TEST--
2-
Cloning datefmt
2+
Cloning datefmt icu <= 4.2
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
56
--FILE--
67
<?php
78
include_once( 'ut_common.inc' );

ext/intl/tests/dateformat_clone2.phpt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
Cloning datefmt icu >= 4.8
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
6+
--FILE--
7+
<?php
8+
include_once( 'ut_common.inc' );
9+
$GLOBALS['oo-mode'] = true;
10+
$res_str = '';
11+
/*
12+
* Clone
13+
*/
14+
$start_pattern = 'dd-MM-YY';
15+
$fmt = ut_datefmt_create( "en-US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
16+
17+
$formatted = ut_datefmt_format($fmt,0);
18+
$res_str .= "\nResult of formatting timestamp=0 is : \n$formatted";
19+
20+
$fmt_clone = clone $fmt;
21+
ut_datefmt_set_pattern( $fmt , 'yyyy-DDD.hh:mm:ss z' );
22+
23+
$formatted = ut_datefmt_format($fmt,0);
24+
$res_str .= "\nResult of formatting timestamp=0 is : \n$formatted";
25+
$formatted = ut_datefmt_format($fmt_clone,0);
26+
$res_str .= "\nResult of clone formatting timestamp=0 is : \n$formatted";
27+
28+
echo $res_str;
29+
30+
?>
31+
--EXPECTF--
32+
Result of formatting timestamp=0 is :
33+
31-12-70
34+
Result of formatting timestamp=0 is :
35+
1969-365.07:00:00 EST
36+
Result of clone formatting timestamp=0 is :
37+
31-12-70

ext/intl/tests/dateformat_get_set_pattern.phpt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--TEST--
2-
datefmt_get_pattern_code and datefmt_set_pattern_code()
2+
datefmt_get_pattern_code and datefmt_set_pattern_code() icu <= 4.2
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
56
--FILE--
67

78
<?php
@@ -81,4 +82,4 @@ Result of formatting timestamp=0 with the new pattern is :
8182
Setting IntlDateFormatter with pattern = yyyyMMdd
8283
After call to get_pattern : pattern= yyyyMMdd
8384
Result of formatting timestamp=0 with the new pattern is :
84-
19691231
85+
19691231
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
--TEST--
2+
datefmt_get_pattern_code and datefmt_set_pattern_code() icu >= 4.8
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
6+
--FILE--
7+
8+
<?php
9+
10+
/*
11+
* Test for the datefmt_get_pattern & datefmt_set_pattern function
12+
*/
13+
14+
15+
function ut_main()
16+
{
17+
$pattern_arr = array (
18+
'DD-MM-YYYY hh:mm:ss',
19+
'yyyy-DDD.hh:mm:ss z',
20+
"yyyy/MM/dd",
21+
"yyyyMMdd"
22+
);
23+
24+
$res_str = '';
25+
26+
$start_pattern = 'dd-MM-YY';
27+
$res_str .= "\nCreating IntlDateFormatter with pattern = $start_pattern ";
28+
//$fmt = ut_datefmt_create( "en-US", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT , 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
29+
$fmt = ut_datefmt_create( "en-US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
30+
$pattern = ut_datefmt_get_pattern( $fmt);
31+
$res_str .= "\nAfter call to get_pattern : pattern= $pattern";
32+
$formatted = ut_datefmt_format($fmt,0);
33+
$res_str .= "\nResult of formatting timestamp=0 is : \n$formatted";
34+
35+
36+
foreach( $pattern_arr as $pattern_entry )
37+
{
38+
$res_str .= "\n-------------------";
39+
$res_str .= "\nSetting IntlDateFormatter with pattern = $pattern_entry ";
40+
ut_datefmt_set_pattern( $fmt , $pattern_entry );
41+
$pattern = ut_datefmt_get_pattern( $fmt);
42+
$res_str .= "\nAfter call to get_pattern : pattern= $pattern";
43+
$formatted = ut_datefmt_format($fmt,0);
44+
$res_str .= "\nResult of formatting timestamp=0 with the new pattern is : \n$formatted";
45+
$res_str .= "\n";
46+
47+
}
48+
49+
return $res_str;
50+
51+
}
52+
53+
include_once( 'ut_common.inc' );
54+
55+
// Run the test
56+
ut_run();
57+
?>
58+
--EXPECT--
59+
Creating IntlDateFormatter with pattern = dd-MM-YY
60+
After call to get_pattern : pattern= dd-MM-YY
61+
Result of formatting timestamp=0 is :
62+
31-12-70
63+
-------------------
64+
Setting IntlDateFormatter with pattern = DD-MM-YYYY hh:mm:ss
65+
After call to get_pattern : pattern= DD-MM-YYYY hh:mm:ss
66+
Result of formatting timestamp=0 with the new pattern is :
67+
365-12-1970 07:00:00
68+
69+
-------------------
70+
Setting IntlDateFormatter with pattern = yyyy-DDD.hh:mm:ss z
71+
After call to get_pattern : pattern= yyyy-DDD.hh:mm:ss z
72+
Result of formatting timestamp=0 with the new pattern is :
73+
1969-365.07:00:00 EST
74+
75+
-------------------
76+
Setting IntlDateFormatter with pattern = yyyy/MM/dd
77+
After call to get_pattern : pattern= yyyy/MM/dd
78+
Result of formatting timestamp=0 with the new pattern is :
79+
1969/12/31
80+
81+
-------------------
82+
Setting IntlDateFormatter with pattern = yyyyMMdd
83+
After call to get_pattern : pattern= yyyyMMdd
84+
Result of formatting timestamp=0 with the new pattern is :
85+
19691231

ext/intl/tests/dateformat_localtime.phpt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--TEST--
2-
datefmt_localtime_code()
2+
datefmt_localtime_code() icu <= 4.2
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
56
--FILE--
67
<?php
78

ext/intl/tests/dateformat_parse.phpt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--TEST--
2-
datefmt_parse_code()
2+
datefmt_parse_code() icu <= 4.2
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
56
--INI--
67
date.timezone="America/Los_Angeles"
78
--FILE--

ext/intl/tests/dateformat_parse_localtime_parsepos.phpt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--TEST--
2-
datefmt_parse_localtime() with parse pos
2+
datefmt_parse_localtime() with parse pos icu <= 4.2
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
56
--FILE--
67
<?php
78

ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--TEST--
2-
datefmt_parse_timestamp_code() with parse pos
2+
datefmt_parse_timestamp_code() with parse pos icu <= 4.2
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
56
--INI--
67
datetime.timezone="America/Los_Angeles"
78
--ENV--

ext/intl/tests/dateformat_set_timezone_id.phpt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--TEST--
2-
datefmt_set_timezone_id_code()
2+
datefmt_set_timezone_id_code() icu <= 4.2
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
56
--FILE--
67
<?php
78

@@ -72,4 +73,4 @@ Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM C
7273
Trying to set timezone_id= CN
7374
After call to set_timezone_id : timezone_id= CN
7475
Formatting timestamp=0 resulted in Thursday, January 1, 1970 12:00:00 AM GMT+00:00
75-
Formatting timestamp=3600 resulted in Thursday, January 1, 1970 1:00:00 AM GMT+00:00
76+
Formatting timestamp=3600 resulted in Thursday, January 1, 1970 1:00:00 AM GMT+00:00

0 commit comments

Comments
 (0)