Skip to content

Commit 5795665

Browse files
authored
Merge pull request #1 from mtraver/intl-tests
Apply commits from php/php-src that update tests for newer ICU versions
2 parents d88f14a + a280766 commit 5795665

File tree

76 files changed

+1218
-140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1218
-140
lines changed

ext/bcmath/tests/bug60377.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--TEST--
22
bcscale related problem on 64bits platforms
33
--SKIPIF--
4-
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
4+
<?php if(!extension_loaded("bcmath")) die("skip");
5+
if (PHP_INT_SIZE != 8) die("skip: 64-bit only"); ?>
56
--FILE--
67
<?php
78
$var48 = bcscale(634314234334311);

ext/curl/tests/curl_version_variation1.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--TEST--
22
Test curl_version() function : usage variations - test values for $ascii argument
33
--SKIPIF--
4-
<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
4+
<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded");
5+
if (PHP_INT_SIZE != 8) die('skip 64-bit only'); ?>
56
--FILE--
67
<?php
78

ext/exif/tests/exif_tagname_variation1.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
--TEST--
22
Test exif_tagname() function : usage variations - different types for index argument
33
--SKIPIF--
4-
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
4+
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';
5+
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
6+
?>
57
--FILE--
68
<?php
79

ext/gd/tests/imagecolorallocate_variation2.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if(!extension_loaded('gd')) {
88
if(!function_exists('imagecreatetruecolor')) {
99
die('skip imagecreatetruecolor function is not available');
1010
}
11+
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
1112
?>
1213
--FILE--
1314
<?php

ext/gd/tests/imagecolorallocate_variation4.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if(!extension_loaded('gd')) {
88
if(!function_exists('imagecreatetruecolor')) {
99
die('skip imagecreatetruecolor function is not available');
1010
}
11+
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
1112
?>
1213
--FILE--
1314
<?php
@@ -210,4 +211,4 @@ int(657920)
210211

211212
Warning: imagecolorallocate() expects parameter 4 to be long, resource given in %s on line %d
212213
NULL
213-
===DONE===
214+
===DONE===

ext/intl/tests/breakiter_getLocale_basic.phpt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
--TEST--
22
IntlBreakIterator::getLocale(): basic test
33
--SKIPIF--
4-
<?php
5-
if (!extension_loaded('intl'))
6-
die('skip intl extension not enabled');
4+
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '53.1') >= 0) die('skip for ICU < 53.1'); ?>
76
--FILE--
87
<?php
98
ini_set("intl.error_level", E_WARNING);
@@ -18,4 +17,4 @@ var_dump($bi->getLocale(1));
1817
--EXPECT--
1918
string(4) "root"
2019
string(4) "root"
21-
==DONE==
20+
==DONE==
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
IntlBreakIterator::getLocale(): basic test
3+
--SKIPIF--
4+
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
6+
--FILE--
7+
<?php
8+
ini_set("intl.error_level", E_WARNING);
9+
ini_set("intl.default_locale", "pt_PT");
10+
11+
$bi = IntlBreakIterator::createSentenceInstance('pt');
12+
13+
var_dump($bi->getLocale(0));
14+
var_dump($bi->getLocale(1));
15+
?>
16+
==DONE==
17+
--EXPECT--
18+
string(4) "root"
19+
string(2) "pt"
20+
==DONE==

ext/intl/tests/bug53512.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
--TEST--
22
Bug #53512 (NumberFormatter::setSymbol crash on bogus $attr values)
33
--SKIPIF--
4-
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
4+
<?php if( !extension_loaded( 'intl' ) ) die('skip');
5+
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
6+
?>
57
--FILE--
68
<?php
79

ext/intl/tests/bug61487.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
--TEST--
22
grapheme() str[i]pos limits
33
--SKIPIF--
4-
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
4+
<?php if( !extension_loaded( 'intl' ) ) die('skip');
5+
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
6+
?>
57
--FILE--
68
<?php
79
var_dump(grapheme_stripos(1,1,2147483648));

ext/intl/tests/bug62070_2.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Bug #62070: Collator::getSortKey() returns garbage
33
--SKIPIF--
44
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
55
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
6+
<?php if (version_compare(INTL_ICU_VERSION, '62.1') >= 0) die('skip for ICU < 62.1'); ?>
67
--FILE--
78
<?php
89
$s1 = 'Hello';

ext/intl/tests/bug62070_3.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #62070: Collator::getSortKey() returns garbage
3+
--SKIPIF--
4+
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?>
6+
--FILE--
7+
<?php
8+
$s1 = 'Hello';
9+
10+
$coll = collator_create('en_US');
11+
$res = collator_get_sort_key($coll, $s1);
12+
13+
echo urlencode($res);
14+
--EXPECT--
15+
82%40%40F%01%09%01%DC%08

ext/intl/tests/bug67052.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Bug #67052 - NumberFormatter::parse() resets LC_NUMERIC setting
66
if (substr(PHP_OS, 0, 3) == 'WIN') {
77
die("skip Valid only on non Windows");
88
}
9+
$l = setlocale(LC_ALL, 'de_DE');
10+
if($l === false) {
11+
die("skip de_DE locale not installed");
12+
}
13+
setlocale(LC_ALL, $l);
914
?>
1015
--FILE--
1116
<?php

ext/intl/tests/calendar_getDayOfWeekType_basic.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ date.timezone=Atlantic/Azores
66
<?php
77
if (!extension_loaded('intl'))
88
die('skip intl extension not enabled');
9-
if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
10-
die('skip for ICU 4.4+');
9+
if (version_compare(INTL_ICU_VERSION, '4.4') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0)
10+
die('skip for ICU >= 4.4 and ICU < 52.1');
1111
--FILE--
1212
<?php
1313
ini_set("intl.error_level", E_WARNING);
@@ -31,4 +31,4 @@ int(0)
3131
int(0)
3232
int(0)
3333
int(1)
34-
==DONE==
34+
==DONE==
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
IntlCalendar::getDayOfWeekType() basic test
3+
--INI--
4+
date.timezone=Atlantic/Azores
5+
--SKIPIF--
6+
<?php
7+
if (!extension_loaded('intl'))
8+
die('skip intl extension not enabled');
9+
if (version_compare(INTL_ICU_VERSION, '52.1') < 0)
10+
die('skip for ICU >= 52.1');
11+
--FILE--
12+
<?php
13+
ini_set("intl.error_level", E_WARNING);
14+
ini_set("intl.default_locale", "nl");
15+
16+
$intlcal = IntlCalendar::createInstance('UTC');
17+
$intlcal->setTime(strtotime('2012-02-29 00:00:00 +0000') * 1000);
18+
var_dump(
19+
intlcal_get_day_of_week_type($intlcal, IntlCalendar::DOW_SUNDAY),
20+
$intlcal->getDayOfWeekType(IntlCalendar::DOW_MONDAY),
21+
$intlcal->getDayOfWeekType(IntlCalendar::DOW_TUESDAY),
22+
$intlcal->getDayOfWeekType(IntlCalendar::DOW_FRIDAY),
23+
$intlcal->getDayOfWeekType(IntlCalendar::DOW_SATURDAY)
24+
);
25+
26+
?>
27+
==DONE==
28+
--EXPECT--
29+
int(1)
30+
int(0)
31+
int(0)
32+
int(0)
33+
int(1)
34+
==DONE==

ext/intl/tests/collator_get_locale2.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ get_locale() icu >= 4.8
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
55
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
6+
<?php if (PHP_INT_SIZE != 8) die('skip 64-bit only'); ?>
67
--FILE--
78
<?php
89

ext/intl/tests/collator_get_sort_key_variant4.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
collator_get_sort_key() icu >= 54.1
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '55.1') >= 0) die('skip for ICU < 55.1'); ?>
56
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
67
--FILE--
78
<?php
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
--TEST--
2+
collator_get_sort_key() icu >= 54.1
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '55.1') < 0) die('skip for ICU >= 55.1'); ?>
6+
--FILE--
7+
<?php
8+
9+
/*
10+
* Get sort keys using various locales
11+
*/
12+
function sort_arrays( $locale, $data )
13+
{
14+
$res_str = '';
15+
16+
$coll = ut_coll_create( $locale );
17+
18+
foreach($data as $value) {
19+
$res_val = ut_coll_get_sort_key( $coll, $value );
20+
$res_str .= "source: ".$value."\n".
21+
"key: ".bin2hex($res_val)."\n";
22+
}
23+
24+
return $res_str;
25+
}
26+
27+
28+
function ut_main()
29+
{
30+
$res_str = '';
31+
32+
// Regular strings keys
33+
$test_params = array(
34+
'abc', 'abd', 'aaa',
35+
'аа', 'а', 'z',
36+
'', null , '3',
37+
'y' , 'i' , 'k'
38+
);
39+
40+
$res_str .= sort_arrays( 'en_US', $test_params );
41+
42+
// Sort a non-ASCII array using ru_RU locale.
43+
$test_params = array(
44+
'абг', 'абв', 'жжж', 'эюя'
45+
);
46+
47+
$res_str .= sort_arrays( 'ru_RU', $test_params );
48+
49+
// Sort an array using Lithuanian locale.
50+
$res_str .= sort_arrays( 'lt_LT', $test_params );
51+
52+
return $res_str . "\n";
53+
}
54+
55+
include_once( 'ut_common.inc' );
56+
ut_run();
57+
?>
58+
--EXPECT--
59+
source: abc
60+
key: 292b2d01070107
61+
source: abd
62+
key: 292b2f01070107
63+
source: aaa
64+
key: 29292901070107
65+
source: аа
66+
key: 60060601060106
67+
source: а
68+
key: 600601050105
69+
source: z
70+
key: 5b01050105
71+
source:
72+
key: 0101
73+
source:
74+
key: 0101
75+
source: 3
76+
key: 1801050105
77+
source: y
78+
key: 5901050105
79+
source: i
80+
key: 3901050105
81+
source: k
82+
key: 3d01050105
83+
source: абг
84+
key: 26060c1001070107
85+
source: абв
86+
key: 26060c0e01070107
87+
source: жжж
88+
key: 2626262601070107
89+
source: эюя
90+
key: 26b4b6ba01070107
91+
source: абг
92+
key: 60060c1001070107
93+
source: абв
94+
key: 60060c0e01070107
95+
source: жжж
96+
key: 6026262601070107
97+
source: эюя
98+
key: 60b4b6ba01070107

0 commit comments

Comments
 (0)