Skip to content

Commit

Permalink
Merge branch 'PHP-8.2' into PHP-8.3
Browse files Browse the repository at this point in the history
* PHP-8.2:
  Adapt ext/intl tests for ICU 75.1 and 76.1
  • Loading branch information
cmb69 committed Nov 15, 2024
2 parents a570e09 + f725f50 commit 716b03d
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 18 deletions.
1 change: 1 addition & 0 deletions ext/intl/tests/bug62070_3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Bug #62070: Collator::getSortKey() returns garbage
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '76.1') >= 0) die('skip for ICU < 76.1'); ?>
--FILE--
<?php
$s1 = 'Hello';
Expand Down
17 changes: 17 additions & 0 deletions ext/intl/tests/bug62070_icu76_1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Bug #62070: Collator::getSortKey() returns garbage
--EXTENSIONS--
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '76.1') < 0) die('skip for ICU >= 76.1'); ?>
--FILE--
<?php
$s1 = 'Hello';

$coll = collator_create('en_US');
$res = collator_get_sort_key($coll, $s1);

echo urlencode($res);
?>
--EXPECT--
93AAG%01%09%01%DC%08
1 change: 1 addition & 0 deletions ext/intl/tests/collator_get_sort_key_variant7.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ collator_get_sort_key() icu >= 62.1
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '76.1') >= 0) die('skip for ICU < 76.1'); ?>
--FILE--
<?php

Expand Down
97 changes: 97 additions & 0 deletions ext/intl/tests/collator_get_sort_key_variant_icu76_1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
--TEST--
collator_get_sort_key() icu >= 62.1
--EXTENSIONS--
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '76.1') < 0) die('skip for ICU >= 76.1'); ?>
--FILE--
<?php

/*
* Get sort keys using various locales
*/
function sort_arrays( $locale, $data )
{
$res_str = '';

$coll = ut_coll_create( $locale );

foreach($data as $value) {
$res_val = ut_coll_get_sort_key( $coll, $value );
$res_str .= "source: ".$value."\n".
"key: ".bin2hex($res_val)."\n";
}

return $res_str;
}


function ut_main()
{
$res_str = '';

// Regular strings keys
$test_params = array(
'abc', 'abd', 'aaa',
'аа', 'а', 'z',
'', '3',
'y' , 'i' , 'k'
);

$res_str .= sort_arrays( 'en_US', $test_params );

// Sort a non-ASCII array using ru_RU locale.
$test_params = array(
'абг', 'абв', 'жжж', 'эюя'
);

$res_str .= sort_arrays( 'ru_RU', $test_params );

// Sort an array using Lithuanian locale.
$res_str .= sort_arrays( 'lt_LT', $test_params );

return $res_str . "\n";
}

include_once( 'ut_common.inc' );
ut_run();
?>
--EXPECT--
source: abc
key: 2b2d2f01070107
source: abd
key: 2b2d3101070107
source: aaa
key: 2b2b2b01070107
source: аа
key: 62060601060106
source: а
key: 620601050105
source: z
key: 5d01050105
source:
key: 0101
source: 3
key: 1801050105
source: y
key: 5b01050105
source: i
key: 3b01050105
source: k
key: 3f01050105
source: абг
key: 28060c1001070107
source: абв
key: 28060c0e01070107
source: жжж
key: 282c2c2c01070107
source: эюя
key: 28eef0f401070107
source: абг
key: 62060c1001070107
source: абв
key: 62060c0e01070107
source: жжж
key: 622c2c2c01070107
source: эюя
key: 62eef0f401070107
18 changes: 9 additions & 9 deletions ext/intl/tests/locale_get_display_name8.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,14 @@ disp_locale=fr : display_name=anglais #États-Unis, attribute=islamcal#
disp_locale=de : display_name=Englisch #Vereinigte Staaten, attribute=islamcal#
-----------------
locale='zh-CN-a-myExt-x-private'
disp_locale=en : display_name=Chinese #China, a=myext, Private-Use=private#
disp_locale=fr : display_name=chinois #Chine, a=myext, usage privé=private#
disp_locale=de : display_name=Chinesisch #China, a=myext, Privatnutzung=private#
disp_locale=en : display_name=Chinese #China(, A_MYEXT_X_PRIVATE)?, a=myext, Private-Use=private#
disp_locale=fr : display_name=chinois #Chine(, A_MYEXT_X_PRIVATE)?, a=myext, usage privé=private#
disp_locale=de : display_name=Chinesisch #China(, A_MYEXT_X_PRIVATE)?, a=myext, Privatnutzung=private#
-----------------
locale='en-a-myExt-b-another'
disp_locale=en : display_name=English #a=myext, b=another#
disp_locale=fr : display_name=anglais #a=myext, b=another#
disp_locale=de : display_name=Englisch #a=myext, b=another#
disp_locale=en : display_name=English #(A_MYEXT_B_ANOTHER, )?a=myext, b=another#
disp_locale=fr : display_name=anglais #(A_MYEXT_B_ANOTHER, )?a=myext, b=another#
disp_locale=de : display_name=Englisch #(A_MYEXT_B_ANOTHER, )?a=myext, b=another#
-----------------
locale='de-419-DE'
disp_locale=en : display_name=German #Latin America, DE#
Expand All @@ -337,7 +337,7 @@ disp_locale=fr : display_name=a #Allemagne#
disp_locale=de : display_name=a #Deutschland#
-----------------
locale='ar-a-aaa-b-bbb-a-ccc'
disp_locale=en : display_name=Arabic #a=aaa, b=bbb#
disp_locale=fr : display_name=arabe #a=aaa, b=bbb#
disp_locale=de : display_name=Arabisch #a=aaa, b=bbb#
disp_locale=en : display_name=Arabic #(A_AAA_B_BBB_A_CCC, )?a=aaa, b=bbb#
disp_locale=fr : display_name=arabe #(A_AAA_B_BBB_A_CCC, )?a=aaa, b=bbb#
disp_locale=de : display_name=Arabisch #(A_AAA_B_BBB_A_CCC, )?a=aaa, b=bbb#
-----------------
18 changes: 9 additions & 9 deletions ext/intl/tests/locale_get_display_variant2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ disp_locale=fr : display_variant=
disp_locale=de : display_variant=
-----------------
locale='zh-CN-a-myExt-x-private'
disp_locale=en : display_variant=
disp_locale=fr : display_variant=
disp_locale=de : display_variant=
disp_locale=en : display_variant=(A_MYEXT_X_PRIVATE)?
disp_locale=fr : display_variant=(A_MYEXT_X_PRIVATE)?
disp_locale=de : display_variant=(A_MYEXT_X_PRIVATE)?
-----------------
locale='en-a-myExt-b-another'
disp_locale=en : display_variant=(MYEXT_B_ANOTHER)?
disp_locale=fr : display_variant=(MYEXT_B_ANOTHER)?
disp_locale=de : display_variant=(MYEXT_B_ANOTHER)?
disp_locale=en : display_variant=((A_)?MYEXT_B_ANOTHER)?
disp_locale=fr : display_variant=((A_)?MYEXT_B_ANOTHER)?
disp_locale=de : display_variant=((A_)?MYEXT_B_ANOTHER)?
-----------------
locale='de-419-DE'
disp_locale=en : display_variant=DE
Expand All @@ -268,7 +268,7 @@ disp_locale=fr : display_variant=
disp_locale=de : display_variant=
-----------------
locale='ar-a-aaa-b-bbb-a-ccc'
disp_locale=en : display_variant=(AAA_B_BBB_A_CCC)?
disp_locale=fr : display_variant=(AAA_B_BBB_A_CCC)?
disp_locale=de : display_variant=(AAA_B_BBB_A_CCC)?
disp_locale=en : display_variant=((A_)?AAA_B_BBB_A_CCC)?
disp_locale=fr : display_variant=((A_)?AAA_B_BBB_A_CCC)?
disp_locale=de : display_variant=((A_)?AAA_B_BBB_A_CCC)?
-----------------
1 change: 1 addition & 0 deletions ext/intl/tests/timezone_IDforWindowsID_basic2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ IntlTimeZone::getIDForWindowsID basic test
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '58.1') < 0) die('skip for ICU >= 58.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '76.1') >= 0) die('skip for ICU <= 76.1'); ?>
--FILE--
<?php

Expand Down
44 changes: 44 additions & 0 deletions ext/intl/tests/timezone_IDforWindowsID_basic_icu76_1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--TEST--
IntlTimeZone::getIDForWindowsID basic test
--EXTENSIONS--
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '76.1') < 0) die('skip for ICU >= 76.1'); ?>
--FILE--
<?php

$tzs = array(
'Gnomeregan' => array(NULL),
'India Standard Time' => array(NULL),
'Pacific Standard Time' => array('001', 'CA', 'MX', 'US', 'ZZ'),
'Romance Standard Time' => array('001', 'BE', 'DK', 'ES', 'FR'),
);

foreach ($tzs as $tz => $regions) {
echo "** $tz\n";
foreach ($regions as $region) {
var_dump(IntlTimeZone::getIDForWindowsID($tz, $region));
if (intl_get_error_code() != U_ZERO_ERROR) {
echo "Error: ", intl_get_error_message(), "\n";
}
}
}
?>
--EXPECTF--
** Gnomeregan
bool(false)
Error: %snknown windows timezone: U_ILLEGAL_ARGUMENT_ERROR
** India Standard Time
string(13) "Asia/Calcutta"
** Pacific Standard Time
string(19) "America/Los_Angeles"
string(17) "America/Vancouver"
string(19) "America/Los_Angeles"
string(19) "America/Los_Angeles"
string(19) "America/Los_Angeles"
** Romance Standard Time
string(12) "Europe/Paris"
string(15) "Europe/Brussels"
string(17) "Europe/Copenhagen"
string(13) "Europe/Madrid"
string(12) "Europe/Paris"

0 comments on commit 716b03d

Please sign in to comment.