diff options
Diffstat (limited to 'ext/intl/tests')
23 files changed, 359 insertions, 30 deletions
diff --git a/ext/intl/tests/bug60192-compare.phpt b/ext/intl/tests/bug60192-compare.phpt index 12f3273538..ce9728023a 100644 --- a/ext/intl/tests/bug60192-compare.phpt +++ b/ext/intl/tests/bug60192-compare.phpt @@ -16,4 +16,8 @@ $c = new Collator2(); $a = $c->compare('h', 'H'); --EXPECTF-- -Catchable fatal error: Collator::compare(): Object not initialized in %s on line %d +Fatal error: Uncaught Error: Object not initialized in %s:%d +Stack trace: +#0 %s(%d): Collator->compare('h', 'H') +#1 {main} + thrown in %s on line %d diff --git a/ext/intl/tests/bug60192-getlocale.phpt b/ext/intl/tests/bug60192-getlocale.phpt index 9f340c5f67..c4155e9ab5 100644 --- a/ext/intl/tests/bug60192-getlocale.phpt +++ b/ext/intl/tests/bug60192-getlocale.phpt @@ -17,4 +17,8 @@ $c = new Collator2(); $c->getLocale(Locale::ACTUAL_LOCALE); --EXPECTF-- -Catchable fatal error: Collator::getLocale(): Object not initialized in %s on line %d +Fatal error: Uncaught Error: Object not initialized in %s:%d +Stack trace: +#0 %s(%d): Collator->getLocale(0) +#1 {main} + thrown in %s on line %d diff --git a/ext/intl/tests/bug60192-getsortkey.phpt b/ext/intl/tests/bug60192-getsortkey.phpt index f3e68f9c61..0d0f07e768 100644 --- a/ext/intl/tests/bug60192-getsortkey.phpt +++ b/ext/intl/tests/bug60192-getsortkey.phpt @@ -17,4 +17,8 @@ $c = new Collator2(); $c->getSortKey('h'); --EXPECTF-- -Catchable fatal error: Collator::getSortKey(): Object not initialized in %s on line %d +Fatal error: Uncaught Error: Object not initialized in %s:%d +Stack trace: +#0 %s(%d): Collator->getSortKey('h') +#1 {main} + thrown in %s on line %d diff --git a/ext/intl/tests/bug60192-sort.phpt b/ext/intl/tests/bug60192-sort.phpt index ee506d3a5a..c452d0de6d 100644 --- a/ext/intl/tests/bug60192-sort.phpt +++ b/ext/intl/tests/bug60192-sort.phpt @@ -18,4 +18,9 @@ $a = array('a', 'b'); $c->sort($a); --EXPECTF-- -Catchable fatal error: Collator::sort(): Object not initialized in %s on line %d +Fatal error: Uncaught Error: Object not initialized in %s:%d +Stack trace: +#0 %s(%d): Collator->sort(Array) +#1 {main} + thrown in %s on line %d + diff --git a/ext/intl/tests/bug60192-sortwithsortkeys.phpt b/ext/intl/tests/bug60192-sortwithsortkeys.phpt index c26b2daf85..e7d7c1dc1d 100644 --- a/ext/intl/tests/bug60192-sortwithsortkeys.phpt +++ b/ext/intl/tests/bug60192-sortwithsortkeys.phpt @@ -18,4 +18,9 @@ $a = array('a', 'b'); $c->sortWithSortKeys($a); --EXPECTF-- -Catchable fatal error: Collator::sortWithSortKeys(): Object not initialized in %s on line %d +Fatal error: Uncaught Error: Object not initialized in %s:%d +Stack trace: +#0 %s(%d): Collator->sortWithSortKeys(Array) +#1 {main} + thrown in %s on line %d + diff --git a/ext/intl/tests/bug69374.phpt b/ext/intl/tests/bug69374.phpt new file mode 100644 index 0000000000..4d9fffab7a --- /dev/null +++ b/ext/intl/tests/bug69374.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlDateFormatter::formatObject(): returns wrong utf8 value when $format param is utf8 string pattern. +--SKIPIF-- +<?php +if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?> +<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') < 0) die('skip for ICU >= 51.1.2'); ?> +--FILE-- +<?php +$millitimestamp = 1428133423941.0; // 14:43:43 April 04 2015 +$pattern1 = '\'tháng\' MM, y'; // yMM format for Vietnamese +$pattern2 = 'y년 MMM'; // yMM format for Korean +$date = IntlCalendar::createInstance('Asia/Ho_Chi_Minh'); +$date->setTime($millitimestamp); +echo IntlDateFormatter::formatObject($date, $pattern1, 'vi_VN'), "\n"; +echo IntlDateFormatter::formatObject ($date, $pattern2, 'ko_KR'), "\n"; +?> +==DONE== + +--EXPECTF-- +tháng 04, 2015 +2015년 4월 +==DONE== + + diff --git a/ext/intl/tests/bug69398.phpt b/ext/intl/tests/bug69398.phpt new file mode 100644 index 0000000000..ea7dbd5098 --- /dev/null +++ b/ext/intl/tests/bug69398.phpt @@ -0,0 +1,22 @@ +--TEST-- +IntlDateFormatter::formatObject(): returns wrong value when time style is NONE. +--SKIPIF-- +<?php +if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?> +<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') < 0) die('skip for ICU >= 51.1.2'); ?> +--FILE-- +<?php +$millitimestamp = 1428133423941.0; // 14:43:43 April 04 2015 +$date = IntlCalendar::createInstance('Asia/Ho_Chi_Minh'); +$date->setTime($millitimestamp); +echo IntlDateFormatter::formatObject($date, array(IntlDateFormatter::SHORT, IntlDateFormatter::NONE), 'vi_VN'), "\n"; +echo IntlDateFormatter::formatObject ($date, array(IntlDateFormatter::SHORT, IntlDateFormatter::NONE), 'ko_KR'), "\n"; +?> +==DONE== + +--EXPECTF-- +04/04/2015 +15. 4. 4. +==DONE== + + diff --git a/ext/intl/tests/bug74298.phpt b/ext/intl/tests/bug74298.phpt new file mode 100644 index 0000000000..0bfb59b48e --- /dev/null +++ b/ext/intl/tests/bug74298.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #74298 (IntlDateFormatter->format() doesn't return microseconds/fractions) +--SKIPIF-- +<?php if (!extension_loaded('intl')) print 'skip'; ?> +--FILE-- +<?php +var_dump((new \DateTime('2017-01-01 01:02:03.123456'))->format('Y-m-d\TH:i:s.u')); + +var_dump((new \IntlDateFormatter( + 'en-US', + \IntlDateFormatter::FULL, + \IntlDateFormatter::FULL, + 'UTC', + \IntlDateFormatter::GREGORIAN, + 'yyyy-MM-dd HH:mm:ss.SSSSSS' +))->format(new \DateTime('2017-01-01 01:02:03.123456', new \DateTimeZone('UTC')))); + +var_dump(datefmt_create( + 'en-US', + \IntlDateFormatter::FULL, + \IntlDateFormatter::FULL, + 'UTC', + \IntlDateFormatter::GREGORIAN, + 'yyyy-MM-dd HH:mm:ss.SSSSSS' +)->format(new \DateTime('2017-01-01 01:02:03.123456', new \DateTimeZone('UTC')))); +?> +--EXPECTF-- +string(26) "2017-01-01T01:02:03.123456" +string(26) "2017-01-01 01:02:03.123000" +string(26) "2017-01-01 01:02:03.123000" diff --git a/ext/intl/tests/dateformat_bug65683.phpt b/ext/intl/tests/dateformat_bug65683.phpt new file mode 100644 index 0000000000..d18cb4c3da --- /dev/null +++ b/ext/intl/tests/dateformat_bug65683.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #65683 IntlDateFormatter accepts DateTimeImmutable +--SKIPIF-- +<?php +if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?> +--FILE-- +<?php + +$formatter = new IntlDateFormatter('en-US', IntlDateFormatter::FULL, IntlDateFormatter::NONE, new DateTimeZone("UTC")); +var_dump($formatter->format(new DateTimeImmutable('2017-03-27 00:00:00 UTC'))) . "\n"; + +?> +==DONE== +--EXPECTF-- +string(%s) "Monday, March %d, 2017" +==DONE== diff --git a/ext/intl/tests/dateformat_format.phpt b/ext/intl/tests/dateformat_format.phpt index 241c5f975a..a0135a809c 100644 --- a/ext/intl/tests/dateformat_format.phpt +++ b/ext/intl/tests/dateformat_format.phpt @@ -400,24 +400,24 @@ Formatted DateTime is : 20001230 05:04 PM Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' diff --git a/ext/intl/tests/dateformat_format_variant2.phpt b/ext/intl/tests/dateformat_format_variant2.phpt index 07c67e9322..a3df39aa95 100644 --- a/ext/intl/tests/dateformat_format_variant2.phpt +++ b/ext/intl/tests/dateformat_format_variant2.phpt @@ -400,24 +400,24 @@ Formatted DateTime is : 20001230 05:04 PM Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' diff --git a/ext/intl/tests/dateformat_format_variant3.phpt b/ext/intl/tests/dateformat_format_variant3.phpt index d770473f44..da0d662ca7 100644 --- a/ext/intl/tests/dateformat_format_variant3.phpt +++ b/ext/intl/tests/dateformat_format_variant3.phpt @@ -400,24 +400,24 @@ Formatted DateTime is : 20001230 05:04 PM Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' diff --git a/ext/intl/tests/formatter_fail.phpt b/ext/intl/tests/formatter_fail.phpt index 72335e2022..dcc5cb24fa 100644 --- a/ext/intl/tests/formatter_fail.phpt +++ b/ext/intl/tests/formatter_fail.phpt @@ -66,7 +66,7 @@ foreach($args as $arg) { ?> --EXPECTF-- -TypeError: NumberFormatter::__construct() expects at least 2 parameters, 0 given in %s on line %d +ArgumentCountError: NumberFormatter::__construct() expects at least 2 parameters, 0 given in %s on line %d 'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' Warning: numfmt_create() expects at least 2 parameters, 0 given in %s on line %d diff --git a/ext/intl/tests/grapheme.phpt b/ext/intl/tests/grapheme.phpt index def9110d0d..251b1d142f 100644 --- a/ext/intl/tests/grapheme.phpt +++ b/ext/intl/tests/grapheme.phpt @@ -68,9 +68,13 @@ function ut_main() array( "abc", "a", 0 ), array( "abc", "a", 0, 0 ), array( "abc", "a", 1, "false" ), + array( "abc", "a", -1, "false" ), array( "ababc", "a", 1, 2 ), array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", -1, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", -5, 6 ), array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, -4, 3 ), array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ), array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ), @@ -91,6 +95,7 @@ function ut_main() array( "ababc", "ab", 1, 2 ), array( "ababc", "abc", 1, 2 ), array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", -8, 6 ), array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ), ); @@ -120,10 +125,12 @@ function ut_main() $tests = array( array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Oo", "o", -6, 6 ), array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ), array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ), array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, -1, 4 ), array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ), array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ), array( "Abc", $char_a_ring_nfd, "false" ), @@ -153,6 +160,7 @@ function ut_main() array( "aBc", "abC", 0, 0 ), array( "abc", "aBc", 1, "false" ), array( "ABabc", "AB", 1, 2 ), + array( "ABabc", "AB", -4, 2 ), array( "abaBc", "aBc", 1, 2 ), array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ), array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ), @@ -559,6 +567,7 @@ function ut_main() array( "abc", 1, 0, 1, "a" ), array( "abc", 1, 1, 2, "b" ), array( "abc", 1, 2, 3, "c" ), + array( "abc", 1, -2, 2, "b" ), array( "abc", 0, 2, 2, "" ), array( "http://news.bbc.co.uk/2/hi/middle_east/7831588.stm", 48, 48 , 50 , "tm" ), @@ -569,8 +578,11 @@ function ut_main() array( $char_a_ring_nfd . "bc", 2, 0, 4, $char_a_ring_nfd . "b" ), array( $char_a_ring_nfd . "bc", 1, 0, 3, $char_a_ring_nfd . "" ), array( $char_a_ring_nfd . "bcde", 2, 3, 5, "bc" ), + array( $char_a_ring_nfd . "bcde", 2, -4, 5, "bc" ), array( $char_a_ring_nfd . "bcde", 2, 4, 6, "cd" ), + array( $char_a_ring_nfd . "bcde", 2, -7, 4, $char_a_ring_nfd . "b" ), array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, 5, 11, "de" . $char_a_ring_nfd . "f" ), + array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, -6, 11, "de" . $char_a_ring_nfd . "f" ), array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, $char_a_ring_nfd . $char_o_diaeresis_nfd ), @@ -794,9 +806,13 @@ find "b" in "abc" - grapheme_strpos = 1 == 1 find "a" in "abc" - grapheme_strpos = 0 == 0 find "a" in "abc" - grapheme_strpos from 0 = 0 == 0 find "a" in "abc" - grapheme_strpos from 1 = false == false +find "a" in "abc" - grapheme_strpos from -1 = false == false find "a" in "ababc" - grapheme_strpos from 1 = 2 == 2 find "o" in "aoa%CC%8Abco%CC%88o" - grapheme_strpos from 2 = 6 == 6 +find "o" in "aoa%CC%8Abco%CC%88o" - grapheme_strpos from -1 = 6 == 6 +find "o" in "aoa%CC%8Abco%CC%88o" - grapheme_strpos from -5 = 6 == 6 find "a%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abc" - grapheme_strpos from 2 = 3 == 3 +find "a%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abc" - grapheme_strpos from -4 = 3 == 3 find "op" in "aa%CC%8Abco%CC%88opq" - grapheme_strpos = 5 == 5 find "opq" in "aa%CC%8Abco%CC%88opq" - grapheme_strpos = 5 == 5 find "abc" in "aa%CC%8Abco%CC%88" - grapheme_strpos = false == false @@ -816,15 +832,18 @@ find "abc" in "abc" - grapheme_strpos from 1 = false == false find "ab" in "ababc" - grapheme_strpos from 1 = 2 == 2 find "abc" in "ababc" - grapheme_strpos from 1 = 2 == 2 find "oa%CC%8Abc" in "aoa%CC%8Abco%CC%88oa%CC%8Abc" - grapheme_strpos from 2 = 6 == 6 +find "oa%CC%8Abc" in "aoa%CC%8Abco%CC%88oa%CC%8Abc" - grapheme_strpos from -8 = 6 == 6 find "a%CC%8Abca%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abca%CC%8Adef" - grapheme_strpos from 2 = 3 == 3 function grapheme_stripos($haystack, $needle, $offset = 0) {} find "o" in "aoa%CC%8Abco%CC%88O" - grapheme_stripos from 2 = 6 == 6 +find "o" in "aoa%CC%8Abco%CC%88Oo" - grapheme_stripos from -6 = 6 == 6 find "a%CC%8A" in "o%CC%88a%CC%8AaA%CC%8Abc" - grapheme_stripos from 2 = 3 == 3 find "o" in "aa%CC%8Abco%CC%88O" - grapheme_stripos = 5 == 5 find "O" in "aa%CC%8Abco%CC%88" - grapheme_stripos = false == false find "o%CC%88" in "aa%CC%8AbcO%CC%88" - grapheme_stripos = 4 == 4 +find "o%CC%88" in "aa%CC%8AbcO%CC%88" - grapheme_stripos from -1 = 4 == 4 find "A%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_stripos = 2 == 2 find "a%CC%8A" in "aA%CC%8Abc" - grapheme_stripos = 1 == 1 find "a%CC%8A" in "Abc" - grapheme_stripos = false == false @@ -853,6 +872,7 @@ find "ab" in "ABc" - grapheme_stripos from 0 = 0 == 0 find "abC" in "aBc" - grapheme_stripos from 0 = 0 == 0 find "aBc" in "abc" - grapheme_stripos from 1 = false == false find "AB" in "ABabc" - grapheme_stripos from 1 = 2 == 2 +find "AB" in "ABabc" - grapheme_stripos from -4 = 2 == 2 find "aBc" in "abaBc" - grapheme_stripos from 1 = 2 == 2 find "Oa%CC%8AbC" in "aoa%CC%8Abco%CC%88oA%CC%8AbC" - grapheme_stripos from 2 = 6 == 6 find "a%CC%8ABca%CC%8A" in "o%CC%88a%CC%8AaA%CC%8AbCa%CC%8Adef" - grapheme_stripos from 2 = 3 == 3 @@ -1094,6 +1114,7 @@ extract from "abc" "0" graphemes - grapheme_extract starting at byte position 0 extract from "abc" "1" graphemes - grapheme_extract starting at byte position 0 with $next = a == a $next=1 == 1 extract from "abc" "1" graphemes - grapheme_extract starting at byte position 1 with $next = b == b $next=2 == 2 extract from "abc" "1" graphemes - grapheme_extract starting at byte position 2 with $next = c == c $next=3 == 3 +extract from "abc" "1" graphemes - grapheme_extract starting at byte position -2 with $next = b == b $next=2 == 2 extract from "abc" "0" graphemes - grapheme_extract starting at byte position 2 with $next = == $next=2 == 2 extract from "http%3A%2F%2Fnews.bbc.co.uk%2F2%2Fhi%2Fmiddle_east%2F7831588.stm" "48" graphemes - grapheme_extract starting at byte position 48 with $next = tm == tm $next=50 == 50 extract from "a%CC%8Abc" "3" graphemes - grapheme_extract = a%CC%8Abc == a%CC%8Abc @@ -1103,8 +1124,11 @@ extract from "a%CC%8Abc" "3" graphemes - grapheme_extract starting at byte posit extract from "a%CC%8Abc" "2" graphemes - grapheme_extract starting at byte position 0 with $next = a%CC%8Ab == a%CC%8Ab $next=4 == 4 extract from "a%CC%8Abc" "1" graphemes - grapheme_extract starting at byte position 0 with $next = a%CC%8A == a%CC%8A $next=3 == 3 extract from "a%CC%8Abcde" "2" graphemes - grapheme_extract starting at byte position 3 with $next = bc == bc $next=5 == 5 +extract from "a%CC%8Abcde" "2" graphemes - grapheme_extract starting at byte position -4 with $next = bc == bc $next=5 == 5 extract from "a%CC%8Abcde" "2" graphemes - grapheme_extract starting at byte position 4 with $next = cd == cd $next=6 == 6 +extract from "a%CC%8Abcde" "2" graphemes - grapheme_extract starting at byte position -7 with $next = a%CC%8Ab == a%CC%8Ab $next=4 == 4 extract from "a%CC%8Abcdea%CC%8Af" "4" graphemes - grapheme_extract starting at byte position 5 with $next = dea%CC%8Af == dea%CC%8Af $next=11 == 11 +extract from "a%CC%8Abcdea%CC%8Af" "4" graphemes - grapheme_extract starting at byte position -6 with $next = dea%CC%8Af == dea%CC%8Af $next=11 == 11 extract from "a%CC%8Ao%CC%88o%CC%88" "3" graphemes - grapheme_extract = a%CC%8Ao%CC%88o%CC%88 == a%CC%8Ao%CC%88o%CC%88 extract from "a%CC%8Ao%CC%88o%CC%88" "2" graphemes - grapheme_extract = a%CC%8Ao%CC%88 == a%CC%8Ao%CC%88 extract from "a%CC%8Ao%CC%88c" "1" graphemes - grapheme_extract = a%CC%8A == a%CC%8A diff --git a/ext/intl/tests/locale_bug72658.phpt b/ext/intl/tests/locale_bug72658.phpt new file mode 100644 index 0000000000..877f0b25f4 --- /dev/null +++ b/ext/intl/tests/locale_bug72658.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #72658 Locale::lookup() / locale_lookup() hangs if no match found +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + +var_dump( + Locale::lookup(['en-Latn-US', 'sl', 'sl-IT'], 'en-US', true, 'de-DE'), + Locale::lookup(['en-Latn-US', 'sl', 'sl-IT'], 'en-US', false, 'de-DE') +); + +?> +==DONE== +--EXPECT-- +string(5) "de-DE" +string(5) "de-DE" +==DONE== diff --git a/ext/intl/tests/msgfmt_fail2.phpt b/ext/intl/tests/msgfmt_fail2.phpt index 5dcd09ccc8..698d19afce 100644 --- a/ext/intl/tests/msgfmt_fail2.phpt +++ b/ext/intl/tests/msgfmt_fail2.phpt @@ -79,7 +79,7 @@ foreach($args as $arg) { ?> --EXPECTF-- -TypeError: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d +ArgumentCountError: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d 'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' Warning: msgfmt_create() expects exactly 2 parameters, 0 given in %s on line %d @@ -88,7 +88,7 @@ Warning: msgfmt_create() expects exactly 2 parameters, 0 given in %s on line %d Warning: MessageFormatter::create() expects exactly 2 parameters, 0 given in %s on line %d 'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' -TypeError: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d +ArgumentCountError: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d 'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' Warning: msgfmt_create() expects exactly 2 parameters, 1 given in %s on line %d diff --git a/ext/intl/tests/msgfmt_format_datetime.phpt b/ext/intl/tests/msgfmt_format_datetime.phpt index 07e7d68f14..bf0d24ba6a 100644 --- a/ext/intl/tests/msgfmt_format_datetime.phpt +++ b/ext/intl/tests/msgfmt_format_datetime.phpt @@ -16,13 +16,16 @@ $fmt = <<<EOD EOD; $dt = new DateTime("2012-05-06 18:00:42", new DateTimeZone("Europe/Lisbon")); +$dti = new DateTimeImmutable("2012-05-06 18:00:42", new DateTimeZone("Europe/Lisbon")); $mf = new MessageFormatter('en_US', $fmt); var_dump($mf->format(array($dt))); +var_dump($mf->format(array($dti))); ?> ==DONE== --EXPECTF-- string(%s) "May %d, 2012 %d:%d:42 %s" +string(%s) "May %d, 2012 %d:%d:42 %s" ==DONE== diff --git a/ext/intl/tests/msgfmt_format_error5.phpt b/ext/intl/tests/msgfmt_format_error5.phpt index ebbd4550e8..d5f62f9baf 100644 --- a/ext/intl/tests/msgfmt_format_error5.phpt +++ b/ext/intl/tests/msgfmt_format_error5.phpt @@ -20,7 +20,7 @@ $mf = new MessageFormatter('en_US', $fmt); var_dump($mf->format(array("foo" => new stdclass()))); --EXPECTF-- -Warning: MessageFormatter::format(): msgfmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted) in %s on line %d +Warning: MessageFormatter::format(): msgfmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted) in %s on line %d Warning: MessageFormatter::format(): The argument for key 'foo' cannot be used as a date or time in %s on line %d bool(false) diff --git a/ext/intl/tests/timezone_IDforWindowsID_basic.phpt b/ext/intl/tests/timezone_IDforWindowsID_basic.phpt new file mode 100644 index 0000000000..f8e3d33325 --- /dev/null +++ b/ext/intl/tests/timezone_IDforWindowsID_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +IntlTimeZone::getIDForWindowsID basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); ?> +<?php if (version_compare(INTL_ICU_VERSION, '52') < 0)die('skip for ICU >= 52'); ?> +<?php if (version_compare(INTL_ICU_VERSION, '58.1') >= 0) die('skip for ICU <= 57.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"; + } + } +} + +--EXPECT-- +** Gnomeregan +bool(false) +Error: intltz_get_windows_id: Unknown 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(15) "America/Tijuana" +string(19) "America/Los_Angeles" +string(7) "PST8PDT" +** Romance Standard Time +string(12) "Europe/Paris" +string(15) "Europe/Brussels" +string(17) "Europe/Copenhagen" +string(13) "Europe/Madrid" +string(12) "Europe/Paris" diff --git a/ext/intl/tests/timezone_IDforWindowsID_basic2.phpt b/ext/intl/tests/timezone_IDforWindowsID_basic2.phpt new file mode 100644 index 0000000000..d7d865c7a7 --- /dev/null +++ b/ext/intl/tests/timezone_IDforWindowsID_basic2.phpt @@ -0,0 +1,45 @@ +--TEST-- +IntlTimeZone::getIDForWindowsID basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); ?> +<?php if (version_compare(INTL_ICU_VERSION, '58.1') < 0) die('skip for ICU >= 58.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"; + } + } +} + +--EXPECT-- +** Gnomeregan +bool(false) +Error: intltz_get_windows_id: Unknown 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(7) "PST8PDT" +** Romance Standard Time +string(12) "Europe/Paris" +string(15) "Europe/Brussels" +string(17) "Europe/Copenhagen" +string(13) "Europe/Madrid" +string(12) "Europe/Paris" diff --git a/ext/intl/tests/timezone_getCanonicalID_error.phpt b/ext/intl/tests/timezone_getCanonicalID_error.phpt index e268e216a8..b29ca67701 100644 --- a/ext/intl/tests/timezone_getCanonicalID_error.phpt +++ b/ext/intl/tests/timezone_getCanonicalID_error.phpt @@ -11,7 +11,6 @@ ini_set("intl.error_level", E_WARNING); var_dump(IntlTimeZone::getCanonicalID()); var_dump(IntlTimeZone::getCanonicalID(array())); var_dump(IntlTimeZone::getCanonicalID("foo\x81")); -var_dump(IntlTimeZone::getCanonicalID('foobar', null)); --EXPECTF-- @@ -28,8 +27,3 @@ bool(false) Warning: IntlTimeZone::getCanonicalID(): intltz_get_canonical_id: could not convert time zone id to UTF-16 in %s on line %d bool(false) - -Fatal error: Uncaught Error: Cannot pass parameter 2 by reference in %s:%d -Stack trace: -#0 {main} - thrown in %s on line %d diff --git a/ext/intl/tests/timezone_windowsID_basic.phpt b/ext/intl/tests/timezone_windowsID_basic.phpt new file mode 100644 index 0000000000..370dc45b6c --- /dev/null +++ b/ext/intl/tests/timezone_windowsID_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlTimeZone::getWindowsID basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); ?> +<?php if (version_compare(INTL_ICU_VERSION, '52') < 0)die('skip for ICU >= 52'); ?> +<?php if (version_compare(INTL_ICU_VERSION, '58.1') >= 0) die('skip for ICU <= 57.1'); ?> +--FILE-- +<?php + +$tzs = array( + 'America/Bogota', + 'America/Havana', + 'America/Indiana/Knox', + 'America/Los_Angeles', + 'Azeroth/Kalimdor/Durotar', + 'Africa/Casablanca', + 'Asia/Singapore', + 'Australia/Perth', + 'Europe/London', + 'Europe/Istanbul', +); + +foreach ($tzs as $tz) { + var_dump(IntlTimeZone::getWindowsID($tz)); + if (intl_get_error_code() != U_ZERO_ERROR) { + echo "Error: ", intl_get_error_message(), "\n"; + } +} + +--EXPECT-- +string(24) "SA Pacific Standard Time" +string(21) "Eastern Standard Time" +string(21) "Central Standard Time" +string(21) "Pacific Standard Time" +bool(false) +Error: intltz_get_windows_id: Unknown system timezone: U_ILLEGAL_ARGUMENT_ERROR +string(21) "Morocco Standard Time" +string(23) "Singapore Standard Time" +string(26) "W. Australia Standard Time" +string(17) "GMT Standard Time" +string(20) "Turkey Standard Time" diff --git a/ext/intl/tests/timezone_windowsID_basic2.phpt b/ext/intl/tests/timezone_windowsID_basic2.phpt new file mode 100644 index 0000000000..528eaad7db --- /dev/null +++ b/ext/intl/tests/timezone_windowsID_basic2.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlTimeZone::getWindowsID basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); ?> +<?php if (version_compare(INTL_ICU_VERSION, '58.1') < 0) die('skip for ICU >= 58.1'); ?> +--FILE-- +<?php + +$tzs = array( + 'America/Bogota', + 'America/Havana', + 'America/Indiana/Knox', + 'America/Los_Angeles', + 'Azeroth/Kalimdor/Durotar', + 'Africa/Casablanca', + 'Asia/Singapore', + 'Australia/Perth', + 'Europe/London', + 'Europe/Istanbul', +); + +foreach ($tzs as $tz) { + var_dump(IntlTimeZone::getWindowsID($tz)); + if (intl_get_error_code() != U_ZERO_ERROR) { + echo "Error: ", intl_get_error_message(), "\n"; + } +} + +--EXPECT-- +string(24) "SA Pacific Standard Time" +string(18) "Cuba Standard Time" +string(21) "Central Standard Time" +string(21) "Pacific Standard Time" +bool(false) +Error: intltz_get_windows_id: Unknown system timezone: U_ILLEGAL_ARGUMENT_ERROR +string(21) "Morocco Standard Time" +string(23) "Singapore Standard Time" +string(26) "W. Australia Standard Time" +string(17) "GMT Standard Time" +string(20) "Turkey Standard Time" |
