Skip to content

Commit

Permalink
Merge pull request #1 from mtraver/intl-tests
Browse files Browse the repository at this point in the history
Apply commits from php/php-src that update tests for newer ICU versions
  • Loading branch information
mtraver authored Jul 12, 2019
2 parents d88f14a + a280766 commit 5795665
Show file tree
Hide file tree
Showing 76 changed files with 1,218 additions and 140 deletions.
3 changes: 2 additions & 1 deletion ext/bcmath/tests/bug60377.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
--TEST--
bcscale related problem on 64bits platforms
--SKIPIF--
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
<?php if(!extension_loaded("bcmath")) die("skip");
if (PHP_INT_SIZE != 8) die("skip: 64-bit only"); ?>
--FILE--
<?php
$var48 = bcscale(634314234334311);
Expand Down
3 changes: 2 additions & 1 deletion ext/curl/tests/curl_version_variation1.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
--TEST--
Test curl_version() function : usage variations - test values for $ascii argument
--SKIPIF--
<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded");
if (PHP_INT_SIZE != 8) die('skip 64-bit only'); ?>
--FILE--
<?php

Expand Down
4 changes: 3 additions & 1 deletion ext/exif/tests/exif_tagname_variation1.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
--TEST--
Test exif_tagname() function : usage variations - different types for index argument
--SKIPIF--
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
?>
--FILE--
<?php

Expand Down
1 change: 1 addition & 0 deletions ext/gd/tests/imagecolorallocate_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if(!extension_loaded('gd')) {
if(!function_exists('imagecreatetruecolor')) {
die('skip imagecreatetruecolor function is not available');
}
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
?>
--FILE--
<?php
Expand Down
3 changes: 2 additions & 1 deletion ext/gd/tests/imagecolorallocate_variation4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if(!extension_loaded('gd')) {
if(!function_exists('imagecreatetruecolor')) {
die('skip imagecreatetruecolor function is not available');
}
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
?>
--FILE--
<?php
Expand Down Expand Up @@ -210,4 +211,4 @@ int(657920)

Warning: imagecolorallocate() expects parameter 4 to be long, resource given in %s on line %d
NULL
===DONE===
===DONE===
7 changes: 3 additions & 4 deletions ext/intl/tests/breakiter_getLocale_basic.phpt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
--TEST--
IntlBreakIterator::getLocale(): basic test
--SKIPIF--
<?php
if (!extension_loaded('intl'))
die('skip intl extension not enabled');
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '53.1') >= 0) die('skip for ICU < 53.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
Expand All @@ -18,4 +17,4 @@ var_dump($bi->getLocale(1));
--EXPECT--
string(4) "root"
string(4) "root"
==DONE==
==DONE==
20 changes: 20 additions & 0 deletions ext/intl/tests/breakiter_getLocale_basic2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
IntlBreakIterator::getLocale(): basic test
--SKIPIF--
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");

$bi = IntlBreakIterator::createSentenceInstance('pt');

var_dump($bi->getLocale(0));
var_dump($bi->getLocale(1));
?>
==DONE==
--EXPECT--
string(4) "root"
string(2) "pt"
==DONE==
4 changes: 3 additions & 1 deletion ext/intl/tests/bug53512.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
--TEST--
Bug #53512 (NumberFormatter::setSymbol crash on bogus $attr values)
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if( !extension_loaded( 'intl' ) ) die('skip');
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
?>
--FILE--
<?php

Expand Down
4 changes: 3 additions & 1 deletion ext/intl/tests/bug61487.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
--TEST--
grapheme() str[i]pos limits
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if( !extension_loaded( 'intl' ) ) die('skip');
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
?>
--FILE--
<?php
var_dump(grapheme_stripos(1,1,2147483648));
Expand Down
1 change: 1 addition & 0 deletions ext/intl/tests/bug62070_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Bug #62070: Collator::getSortKey() returns garbage
--SKIPIF--
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '62.1') >= 0) die('skip for ICU < 62.1'); ?>
--FILE--
<?php
$s1 = 'Hello';
Expand Down
15 changes: 15 additions & 0 deletions ext/intl/tests/bug62070_3.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Bug #62070: Collator::getSortKey() returns garbage
--SKIPIF--
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?>
--FILE--
<?php
$s1 = 'Hello';

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

echo urlencode($res);
--EXPECT--
82%40%40F%01%09%01%DC%08
5 changes: 5 additions & 0 deletions ext/intl/tests/bug67052.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Bug #67052 - NumberFormatter::parse() resets LC_NUMERIC setting
if (substr(PHP_OS, 0, 3) == 'WIN') {
die("skip Valid only on non Windows");
}
$l = setlocale(LC_ALL, 'de_DE');
if($l === false) {
die("skip de_DE locale not installed");
}
setlocale(LC_ALL, $l);
?>
--FILE--
<?php
Expand Down
6 changes: 3 additions & 3 deletions ext/intl/tests/calendar_getDayOfWeekType_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ date.timezone=Atlantic/Azores
<?php
if (!extension_loaded('intl'))
die('skip intl extension not enabled');
if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
die('skip for ICU 4.4+');
if (version_compare(INTL_ICU_VERSION, '4.4') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0)
die('skip for ICU >= 4.4 and ICU < 52.1');
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
Expand All @@ -31,4 +31,4 @@ int(0)
int(0)
int(0)
int(1)
==DONE==
==DONE==
34 changes: 34 additions & 0 deletions ext/intl/tests/calendar_getDayOfWeekType_basic2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
IntlCalendar::getDayOfWeekType() basic test
--INI--
date.timezone=Atlantic/Azores
--SKIPIF--
<?php
if (!extension_loaded('intl'))
die('skip intl extension not enabled');
if (version_compare(INTL_ICU_VERSION, '52.1') < 0)
die('skip for ICU >= 52.1');
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "nl");

$intlcal = IntlCalendar::createInstance('UTC');
$intlcal->setTime(strtotime('2012-02-29 00:00:00 +0000') * 1000);
var_dump(
intlcal_get_day_of_week_type($intlcal, IntlCalendar::DOW_SUNDAY),
$intlcal->getDayOfWeekType(IntlCalendar::DOW_MONDAY),
$intlcal->getDayOfWeekType(IntlCalendar::DOW_TUESDAY),
$intlcal->getDayOfWeekType(IntlCalendar::DOW_FRIDAY),
$intlcal->getDayOfWeekType(IntlCalendar::DOW_SATURDAY)
);

?>
==DONE==
--EXPECT--
int(1)
int(0)
int(0)
int(0)
int(1)
==DONE==
1 change: 1 addition & 0 deletions ext/intl/tests/collator_get_locale2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ get_locale() icu >= 4.8
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
<?php if (PHP_INT_SIZE != 8) die('skip 64-bit only'); ?>
--FILE--
<?php

Expand Down
1 change: 1 addition & 0 deletions ext/intl/tests/collator_get_sort_key_variant4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
collator_get_sort_key() icu >= 54.1
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if (version_compare(INTL_ICU_VERSION, '55.1') >= 0) die('skip for ICU < 55.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
--FILE--
<?php
Expand Down
98 changes: 98 additions & 0 deletions ext/intl/tests/collator_get_sort_key_variant5.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
--TEST--
collator_get_sort_key() icu >= 54.1
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if (version_compare(INTL_ICU_VERSION, '55.1') < 0) die('skip for ICU >= 55.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',
'', null , '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: 292b2d01070107
source: abd
key: 292b2f01070107
source: aaa
key: 29292901070107
source: аа
key: 60060601060106
source: а
key: 600601050105
source: z
key: 5b01050105
source:
key: 0101
source:
key: 0101
source: 3
key: 1801050105
source: y
key: 5901050105
source: i
key: 3901050105
source: k
key: 3d01050105
source: абг
key: 26060c1001070107
source: абв
key: 26060c0e01070107
source: жжж
key: 2626262601070107
source: эюя
key: 26b4b6ba01070107
source: абг
key: 60060c1001070107
source: абв
key: 60060c0e01070107
source: жжж
key: 6026262601070107
source: эюя
key: 60b4b6ba01070107
Loading

0 comments on commit 5795665

Please sign in to comment.