diff --git a/ext/intl/tests/bug67397.phpt b/ext/intl/tests/bug67397.phpt index 7786c81dd4d00..e36b5afdc8756 100644 --- a/ext/intl/tests/bug67397.phpt +++ b/ext/intl/tests/bug67397.phpt @@ -5,17 +5,17 @@ intl --FILE-- --EXPECT-- -false -'locale_get_display_name : name too long: U_ILLEGAL_ARGUMENT_ERROR' +bool(false) +string(65) "locale_get_display_name : name too long: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +string(65) "locale_get_display_name : name too long: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/bug72533.phpt b/ext/intl/tests/bug72533.phpt index c7cc90f9c3b9a..5fef8684835b2 100644 --- a/ext/intl/tests/bug72533.phpt +++ b/ext/intl/tests/bug72533.phpt @@ -5,26 +5,30 @@ intl --FILE-- --EXPECT-- -false -'locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR' -'en' +bool(false) +string(73) "locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +string(73) "locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +string(73) "locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +string(73) "locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/collator_create4.phpt b/ext/intl/tests/collator_create.phpt similarity index 70% rename from ext/intl/tests/collator_create4.phpt rename to ext/intl/tests/collator_create.phpt index 5747d366dcfa4..2554571ba355f 100644 --- a/ext/intl/tests/collator_create4.phpt +++ b/ext/intl/tests/collator_create.phpt @@ -1,5 +1,5 @@ --TEST-- -create() icu >= 53.1 +Collator creation tests --EXTENSIONS-- intl --FILE-- @@ -17,11 +17,9 @@ function ut_main() $locales = array( 'EN-US-ODESSA', 'UK_UA_ODESSA', - 'uk-ua_CALIFORNIA@currency=;currency=GRN', '', 'root', 'uk@currency=EURO', - '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' ); foreach( $locales as $locale ) @@ -62,7 +60,6 @@ Locale: 'UK_UA_ODESSA' ULOC_REQUESTED_LOCALE = 'UK_UA_ODESSA' ULOC_VALID_LOCALE = 'uk' ULOC_ACTUAL_LOCALE = 'uk' -Error creating collator with 'uk-ua_CALIFORNIA@currency=;currency=GRN' locale: collator_create: unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR Locale: '' ULOC_REQUESTED_LOCALE = '' ULOC_VALID_LOCALE = '%s' @@ -75,4 +72,3 @@ Locale: 'uk@currency=EURO' ULOC_REQUESTED_LOCALE = 'uk@currency=EURO' ULOC_VALID_LOCALE = 'uk' ULOC_ACTUAL_LOCALE = 'uk' -Error creating collator with '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' locale: Locale string too long, should be no longer than %d characters: U_ILLEGAL_ARGUMENT_ERROR diff --git a/ext/intl/tests/collator_create_errors.phpt b/ext/intl/tests/collator_create_errors.phpt new file mode 100644 index 0000000000000..26c2193234490 --- /dev/null +++ b/ext/intl/tests/collator_create_errors.phpt @@ -0,0 +1,40 @@ +--TEST-- +Collator creation errors +--EXTENSIONS-- +intl +--FILE-- +getMessage(), PHP_EOL; + } + + $c = Collator::create($locale); + var_dump($c); + var_dump(intl_get_error_message()); + + $c = collator_create($locale); + var_dump($c); + var_dump(intl_get_error_message()); +} + +?> +--EXPECT-- +IntlException: Constructor failed +NULL +string(70) "collator_create: unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR" +NULL +string(70) "collator_create: unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR" +IntlException: Constructor failed +NULL +string(89) "Locale string too long, should be no longer than 156 characters: U_ILLEGAL_ARGUMENT_ERROR" +NULL +string(89) "Locale string too long, should be no longer than 156 characters: U_ILLEGAL_ARGUMENT_ERROR" \ No newline at end of file diff --git a/ext/intl/tests/collation_customization.phpt b/ext/intl/tests/collator_customization.phpt similarity index 90% rename from ext/intl/tests/collation_customization.phpt rename to ext/intl/tests/collator_customization.phpt index aeb14386fd217..befb2c129e2c2 100644 --- a/ext/intl/tests/collation_customization.phpt +++ b/ext/intl/tests/collator_customization.phpt @@ -6,11 +6,10 @@ intl ---EXPECT-- -U_ZERO_ERROR -Error getting attribute value: U_ILLEGAL_ARGUMENT_ERROR diff --git a/ext/intl/tests/collator_get_invalid_attribute.phpt b/ext/intl/tests/collator_get_invalid_attribute.phpt new file mode 100644 index 0000000000000..26bcb664880e6 --- /dev/null +++ b/ext/intl/tests/collator_get_invalid_attribute.phpt @@ -0,0 +1,23 @@ +--TEST-- +Collator get invalid attribute +--EXTENSIONS-- +intl +--FILE-- +getAttribute($attr)); +var_dump($coll->getErrorMessage()); + +var_dump(collator_get_attribute($coll, $attr)); +var_dump(collator_get_error_message($coll)); + +?> +--EXPECT-- +bool(false) +string(55) "Error getting attribute value: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +string(55) "Error getting attribute value: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/dateformat_calendars_variant3.phpt b/ext/intl/tests/dateformat_calendars_variant.phpt similarity index 60% rename from ext/intl/tests/dateformat_calendars_variant3.phpt rename to ext/intl/tests/dateformat_calendars_variant.phpt index 037d8066a0815..48c44c58834a4 100644 --- a/ext/intl/tests/dateformat_calendars_variant3.phpt +++ b/ext/intl/tests/dateformat_calendars_variant.phpt @@ -8,7 +8,6 @@ intl = 0) die('skip for ICU < 72.1'); ?> --FILE-- format(strtotime('2012-01-01 00:00:00 +0000'))); var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000'))); var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000'))); -new IntlDateFormatter('en_US@calendar=hebrew', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - -1); ?> -==DONE== ---EXPECTF-- +--EXPECT-- string(47) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12" string(47) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12" string(44) "Sunday, 6 Tevet 5772 at 5:12:00 AM GMT+05:12" - -Fatal error: Uncaught IntlException: IntlDateFormatter::__construct(): datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %sdateformat_calendars_variant3.php:%d -Stack trace: -#0 %sdateformat_calendars_variant3.php(%d): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1) -#1 {main} - thrown %sdateformat_calendars_variant3.php on line %d diff --git a/ext/intl/tests/dateformat_calendars_variant_icu72-1.phpt b/ext/intl/tests/dateformat_calendars_variant_icu72-1.phpt index c63b302d8e5e9..d5d0f437d9b64 100644 --- a/ext/intl/tests/dateformat_calendars_variant_icu72-1.phpt +++ b/ext/intl/tests/dateformat_calendars_variant_icu72-1.phpt @@ -8,7 +8,6 @@ intl = 72.1'); ?> --FILE-- format(strtotime('2012-01-01 00:00:00 +0000'))); var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000'))); var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000'))); -new IntlDateFormatter('en_US@calendar=hebrew', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - -1); ?> -==DONE== ---EXPECTF-- +--EXPECT-- string(49) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12" string(49) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12" string(46) "Sunday, 6 Tevet 5772 at 5:12:00 AM GMT+05:12" - -Fatal error: Uncaught IntlException: IntlDateFormatter::__construct(): datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s:%d -Stack trace: -#0 %s(%d): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1) -#1 {main} - thrown in %s on line %d diff --git a/ext/intl/tests/dateformat_errors.phpt b/ext/intl/tests/dateformat_errors.phpt new file mode 100644 index 0000000000000..e02d5e800cbc8 --- /dev/null +++ b/ext/intl/tests/dateformat_errors.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlDateFormatter with invalid locale +--EXTENSIONS-- +intl +--FILE-- +getMessage(), PHP_EOL; +} + +$df = IntlDateFormatter::create($locale, $type, $type, $timezone, $invalidCalendar); +var_dump($df); +var_dump(intl_get_error_message()); + +$df = datefmt_create($locale, $type, $type, $timezone, $invalidCalendar); +var_dump($df); +var_dump(intl_get_error_message()); + +?> +--EXPECT-- +IntlException: datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR +NULL +string(232) "datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR" +NULL +string(232) "datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/dateformat_formatObject_error.phpt b/ext/intl/tests/dateformat_formatObject_error.phpt index f2444a5955167..19c88edb4c43b 100644 --- a/ext/intl/tests/dateformat_formatObject_error.phpt +++ b/ext/intl/tests/dateformat_formatObject_error.phpt @@ -2,54 +2,59 @@ IntlDateFormatter::formatObject(): error conditions --EXTENSIONS-- intl +--INI-- +intl.default_locale=pt_PT +date.timezone=Europe/Lisbon --FILE-- getMessage(), "\n"; + var_dump(intl_get_error_message()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } -$cal = IntlCalendar::createInstance(); +var_dump(IntlDateFormatter::formatObject(new stdclass)); +var_dump(intl_get_error_message()); +var_dump(IntlDateFormatter::formatObject(new A)); +var_dump(intl_get_error_message()); + var_dump(IntlDateFormatter::formatObject($cal, -2)); +var_dump(intl_get_error_message()); var_dump(IntlDateFormatter::formatObject($cal, array())); +var_dump(intl_get_error_message()); var_dump(IntlDateFormatter::formatObject($cal, array(1,2,3))); +var_dump(intl_get_error_message()); var_dump(IntlDateFormatter::formatObject($cal, array(array(), 1))); +var_dump(intl_get_error_message()); var_dump(IntlDateFormatter::formatObject($cal, array(1, -2))); +var_dump(intl_get_error_message()); var_dump(IntlDateFormatter::formatObject($cal, "")); +var_dump(intl_get_error_message()); ?> ---EXPECTF-- -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the passed object must be an instance of either IntlCalendar or DateTimeInterface in %s on line %d +--EXPECT-- +DateObjectError: Object of type B (inheriting DateTime) has not been correctly initialized by calling parent::__construct() in its constructor bool(false) - -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad IntlCalendar instance: not initialized properly in %s on line %d +string(118) "datefmt_format_object: the passed object must be an instance of either IntlCalendar or DateTimeInterface: U_ZERO_ERROR" bool(false) -Object of type B (inheriting DateTime) has not been correctly initialized by calling parent::__construct() in its constructor - -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the date/time format type is invalid in %s on line %d +string(100) "datefmt_format_object: bad IntlCalendar instance: not initialized properly: U_ILLEGAL_ARGUMENT_ERROR" bool(false) - -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; if array, it must have two elements in %s on line %d +string(85) "datefmt_format_object: the date/time format type is invalid: U_ILLEGAL_ARGUMENT_ERROR" bool(false) - -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; if array, it must have two elements in %s on line %d +string(96) "datefmt_format_object: bad format; if array, it must have two elements: U_ILLEGAL_ARGUMENT_ERROR" bool(false) - -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; the date format (first element of the array) is not valid in %s on line %d +string(96) "datefmt_format_object: bad format; if array, it must have two elements: U_ILLEGAL_ARGUMENT_ERROR" bool(false) - -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; the time format (second element of the array) is not valid in %s on line %d +string(118) "datefmt_format_object: bad format; the date format (first element of the array) is not valid: U_ILLEGAL_ARGUMENT_ERROR" bool(false) - -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the format is empty in %s on line %d +string(119) "datefmt_format_object: bad format; the time format (second element of the array) is not valid: U_ILLEGAL_ARGUMENT_ERROR" bool(false) +string(68) "datefmt_format_object: the format is empty: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/dateformat_format_error.phpt b/ext/intl/tests/dateformat_format_error.phpt new file mode 100644 index 0000000000000..fb6da6862141f --- /dev/null +++ b/ext/intl/tests/dateformat_format_error.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlDateFormatter->format() errors +--EXTENSIONS-- +intl +--FILE-- +format($object); +var_dump($v); +var_dump(intl_get_error_message()); + +$v = datefmt_format($f, $object); +var_dump($v); +var_dump(intl_get_error_message()); + +?> +--EXPECT-- +bool(false) +string(127) "datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +string(127) "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 e2d0a02637489..f889f5eef42b4 100644 --- a/ext/intl/tests/dateformat_format_variant3.phpt +++ b/ext/intl/tests/dateformat_format_variant3.phpt @@ -7,8 +7,6 @@ This test assumes wrong data wrt PDT. It is also too big and needs splitting up. --FILE-- setTimezone(new DateTimeZone("PDT")); - $dates = array( - $d1, - $d2, - new StdClass(), - ); //Test format with input as a timestamp : integer foreach( $time_arr as $timestamp_entry){ $res_str .= "\n------------\n"; $res_str .= "\nInput timestamp is : $timestamp_entry"; $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) + foreach( $datetype_arr as $datetype_entry ) { $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN); @@ -98,19 +88,17 @@ function ut_main() $res_str .= "\nFormatted timestamp is : $formatted"; } } - } //Test format with input as a localtime :array foreach( $localtime_arr as $localtime_entry){ $res_str .= "\n------------\n"; $res_str .= "\nInput localtime is : "; foreach( $localtime_entry as $key => $value){ - $res_str .= "$key : '$value' , "; + $res_str .= "$key : '$value' , "; } $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) + foreach( $datetype_arr as $datetype_entry ) { $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); @@ -122,22 +110,23 @@ function ut_main() } } } - } + $dates = array( + $d1, + $d2, + ); foreach($dates as $date_entry) { - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) { - $res_str .= "\n------------"; - $res_str .= "\nDate is: ".var_export($date_entry, true); - $res_str .= "\n------------"; - - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); - $formatted1 = ut_datefmt_format( $fmt , $date_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted DateTime is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } + foreach( $datetype_arr as $datetype_entry ) { + $res_str .= "\n------------"; + $res_str .= "\nDate is: ".var_export($date_entry, true); + $res_str .= "\n------------"; + + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); + $formatted1 = ut_datefmt_format( $fmt , $date_entry); + if( intl_get_error_code() == U_ZERO_ERROR){ + $res_str .= "\nFormatted DateTime is : $formatted1"; + }else{ + $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; } } } @@ -397,28 +386,3 @@ Date is: \DateTime::__set_state(array( )) ------------ Formatted DateTime is : 20001230 05:04 PM ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------- -Date is: (object) array( -) ------------- -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_set_timezone_id3.phpt b/ext/intl/tests/dateformat_set_timezone_id3.phpt index 16c0bb05b9be3..1abd070f5db08 100644 --- a/ext/intl/tests/dateformat_set_timezone_id3.phpt +++ b/ext/intl/tests/dateformat_set_timezone_id3.phpt @@ -22,7 +22,6 @@ function ut_main() 'America/New_York' => true, 'America/Los_Angeles' => true, 'America/Chicago' => true, - 'CN' => false ); $timestamp_entry = 0; @@ -61,10 +60,7 @@ include_once( 'ut_common.inc' ); // Run the test ut_run(); ?> ---EXPECTF-- -datefmt_set_timezone: No such time zone: 'CN' -datefmt_set_timezone: No such time zone: 'CN' - +--EXPECT-- After creation of the dateformatter : timezone_id= US/Pacific ----------- Trying to set timezone_id= America/New_York @@ -81,8 +77,3 @@ Trying to set timezone_id= America/Chicago After call to set_timezone_id : timezone_id= America/Chicago Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 6:00:00 PM Central Standard Time Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Central Standard Time ------------ -Trying to set timezone_id= CN -After call to set_timezone_id : timezone_id= America/Chicago -Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 6:00:00 PM Central Standard Time -Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Central Standard Time diff --git a/ext/intl/tests/dateformat_set_timezone_id_icu72-1.phpt b/ext/intl/tests/dateformat_set_timezone_id_icu72-1.phpt index eebc6f0973a05..68952e10e43b3 100644 --- a/ext/intl/tests/dateformat_set_timezone_id_icu72-1.phpt +++ b/ext/intl/tests/dateformat_set_timezone_id_icu72-1.phpt @@ -1,5 +1,5 @@ --TEST-- -datefmt_set_timezone_id_code() icu >= 4.8 +datefmt_set_timezone_id_code() icu >= 72.1 --INI-- date.timezone=Atlantic/Azores --EXTENSIONS-- @@ -22,7 +22,6 @@ function ut_main() 'America/New_York' => true, 'America/Los_Angeles' => true, 'America/Chicago' => true, - 'CN' => false ); $timestamp_entry = 0; @@ -61,10 +60,7 @@ include_once( 'ut_common.inc' ); // Run the test ut_run(); ?> ---EXPECTF-- -datefmt_set_timezone: No such time zone: 'CN' -datefmt_set_timezone: No such time zone: 'CN' - +--EXPECT-- After creation of the dateformatter : timezone_id= US/Pacific ----------- Trying to set timezone_id= America/New_York @@ -81,8 +77,3 @@ Trying to set timezone_id= America/Chicago After call to set_timezone_id : timezone_id= America/Chicago Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 6:00:00 PM Central Standard Time Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Central Standard Time ------------ -Trying to set timezone_id= CN -After call to set_timezone_id : timezone_id= America/Chicago -Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 6:00:00 PM Central Standard Time -Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Central Standard Time diff --git a/ext/intl/tests/formatter_get_error.phpt b/ext/intl/tests/formatter_get_error.phpt index b8f1269fc65f9..efe4d9f626faa 100644 --- a/ext/intl/tests/formatter_get_error.phpt +++ b/ext/intl/tests/formatter_get_error.phpt @@ -5,27 +5,43 @@ intl --FILE-- parseCurrency('123.45', $currency); +var_dump($currency); +var_dump($nf->getErrorMessage()); +var_dump($nf->getErrorCode()); +$pos = 0; +$nf->parseCurrency('123.45', $currency, $pos); +var_dump($currency); +var_dump($nf->getErrorMessage()); +var_dump($nf->getErrorCode()); -function ut_main() -{ - $fmt = ut_nfmt_create( "en_US", NumberFormatter::CURRENCY ); - $currency = ''; - $pos = 0; - $num = ut_nfmt_parse_currency( $fmt, '123.45', $currency, $pos ); - if( $num === false ) - return $fmt->getErrorMessage() . " (" . $fmt->getErrorCode() . ")\n"; - else - return "Ooops, an error should have occurred."; -} +$nf = numfmt_create("en_US", NumberFormatter::CURRENCY); +var_dump(numfmt_parse_currency($nf, '123.45', $currency)); +var_dump($currency); +var_dump($nf->getErrorMessage()); +var_dump($nf->getErrorCode()); -include_once( 'ut_common.inc' ); +$pos = 0; +var_dump(numfmt_parse_currency($nf, '123.45', $currency, $pos)); +var_dump($currency); +var_dump($nf->getErrorMessage()); +var_dump($nf->getErrorCode()); -// Run the test -ut_run(); ?> --EXPECT-- -Number parsing failed: U_PARSE_ERROR (9) +NULL +string(36) "Number parsing failed: U_PARSE_ERROR" +int(9) +NULL +string(36) "Number parsing failed: U_PARSE_ERROR" +int(9) +bool(false) +NULL +string(36) "Number parsing failed: U_PARSE_ERROR" +int(9) +bool(false) +NULL +string(36) "Number parsing failed: U_PARSE_ERROR" +int(9) diff --git a/ext/intl/tests/formatter_get_set_pattern2.phpt b/ext/intl/tests/formatter_get_set_pattern2.phpt index 0d3e3e87d72dd..7b454ae965eac 100644 --- a/ext/intl/tests/formatter_get_set_pattern2.phpt +++ b/ext/intl/tests/formatter_get_set_pattern2.phpt @@ -37,10 +37,6 @@ function ut_main() ut_nfmt_set_pattern($fmt, str_repeat('@', 200)); $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n"; $res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n"; - $res = ut_nfmt_set_pattern( $fmt, "0.0 .#.#.#"); - if ($res !== false) - die("ut_nfmt_set_pattern should have failed"); - $res_str .= ut_nfmt_get_error_message( $fmt ) . " (" . ut_nfmt_get_error_code( $fmt ) . ")\n"; return $res_str; } @@ -56,4 +52,3 @@ New pattern: '0.0' Formatted number: 12345.1 New pattern: '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' Formatted number: 12345.123456000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -Error setting pattern value at line 0, offset 0: U_UNQUOTED_SPECIAL (65555) diff --git a/ext/intl/tests/formatter_set_invalid_pattern.phpt b/ext/intl/tests/formatter_set_invalid_pattern.phpt new file mode 100644 index 0000000000000..ba2cf8026bc9c --- /dev/null +++ b/ext/intl/tests/formatter_set_invalid_pattern.phpt @@ -0,0 +1,21 @@ +--TEST-- +numfmt_set_pattern() with invalid pattern +--EXTENSIONS-- +intl +--FILE-- +setPattern($pattern)); +var_dump($fmt->getErrorMessage()); +var_dump(numfmt_set_pattern($fmt, $pattern)); +var_dump(numfmt_get_error_message($fmt)); + +?> +--EXPECT-- +bool(false) +string(67) "Error setting pattern value at line 0, offset 0: U_UNQUOTED_SPECIAL" +bool(false) +string(67) "Error setting pattern value at line 0, offset 0: U_UNQUOTED_SPECIAL" diff --git a/ext/intl/tests/gh17469.phpt b/ext/intl/tests/gh17469.phpt index a0c5d719817d7..bb0c7aaf73fdf 100644 --- a/ext/intl/tests/gh17469.phpt +++ b/ext/intl/tests/gh17469.phpt @@ -1,5 +1,7 @@ --TEST-- GH-17469: UConverter::transcode() raises always E_WARNING regardless of INI settings +--EXTENSIONS-- +intl --SKIPIF-- 'sl' , - Locale::SCRIPT_TAG =>'Latn' , - Locale::REGION_TAG =>'IT' + Locale::LANG_TAG => 'sl', + Locale::SCRIPT_TAG => 'Latn', + Locale::REGION_TAG => 'IT' ); $loc_parts_arr2 = array( - Locale::LANG_TAG =>'de' , - Locale::REGION_TAG =>'DE' + Locale::LANG_TAG => 'de', + Locale::REGION_TAG => 'DE' ); $loc_parts_arr3 = array( - Locale::LANG_TAG =>'hi' + Locale::LANG_TAG => 'hi' ); $loc_parts_arr4 = array( - Locale::LANG_TAG =>'zh' , - Locale::SCRIPT_TAG =>'Hans' , - Locale::REGION_TAG =>'CN' + Locale::LANG_TAG => 'zh', + Locale::SCRIPT_TAG => 'Hans', + Locale::REGION_TAG => 'CN' ); $loc_parts_arr5 = array( - Locale::LANG_TAG =>'es' , - Locale::SCRIPT_TAG =>'Hans' , - Locale::REGION_TAG =>'CN' + Locale::LANG_TAG => 'es', + Locale::SCRIPT_TAG => 'Hans', + Locale::REGION_TAG => 'CN' ); $loc_parts_arr6 = array( - Locale::LANG_TAG =>'en' , - Locale::SCRIPT_TAG =>'Hans' , - Locale::REGION_TAG =>'CN', - Locale::VARIANT_TAG.'14' =>'rozaj' , - 'variant1'=>'nedis' + Locale::LANG_TAG => 'en', + Locale::SCRIPT_TAG => 'Hans', + Locale::REGION_TAG => 'CN', + Locale::VARIANT_TAG.'14' => 'rozaj', + 'variant1' => 'nedis' ); $loc_parts_arr7 = array( - Locale::LANG_TAG =>'en' , - Locale::SCRIPT_TAG =>'Hans' , - Locale::REGION_TAG =>'CN', - 'variant14'=>'rozaj' , - 'variant1'=>'nedis' , - 'extlang0'=>'lng' , - 'extlang1'=>'ing' + Locale::LANG_TAG => 'en', + Locale::SCRIPT_TAG => 'Hans', + Locale::REGION_TAG => 'CN', + 'variant14' => 'rozaj', + 'variant1' => 'nedis', + 'extlang0' => 'lng', + 'extlang1' => 'ing' ); $loc_parts_arr8 = array( - Locale::LANG_TAG =>'en' , - Locale::SCRIPT_TAG =>'Hans' , - Locale::REGION_TAG =>'CN', - 'variant14'=>'rozaj' , - 'variant1'=>'nedis' , - 'extlang0'=>'lng' , - 'extlang1'=>'ing', - 'private7'=>'prv1' , - 'private9'=>'prv2' + Locale::LANG_TAG => 'en', + Locale::SCRIPT_TAG => 'Hans', + Locale::REGION_TAG => 'CN', + 'variant14' => 'rozaj', + 'variant1' => 'nedis', + 'extlang0' => 'lng', + 'extlang1' => 'ing', + 'private7' => 'prv1', + 'private9' => 'prv2' ); $loc_parts_arr9 = array( - Locale::REGION_TAG =>'DE' - ); - $loc_parts_arr10 = array( - Locale::LANG_TAG => 45, - Locale::REGION_TAG => false, - Locale::SCRIPT_TAG => 15 - ); - $loc_parts_arr11 = array( - Locale::LANG_TAG =>'de' , - Locale::REGION_TAG =>'DE', - 'private0' => 13, - 'variant1' => array(), - 'extlang2' => false - ); - $loc_parts_arr12 = array( - Locale::LANG_TAG =>'en' , - Locale::SCRIPT_TAG =>'Hans' , - Locale::REGION_TAG =>'CN', - Locale::VARIANT_TAG => array('nedis', 'rozaj'), + Locale::LANG_TAG => 'en', + Locale::SCRIPT_TAG => 'Hans', + Locale::REGION_TAG => 'CN', + Locale::VARIANT_TAG => array('nedis', 'rozaj'), Locale::PRIVATE_TAG => array('prv1', 'prv2'), Locale::EXTLANG_TAG => array('lng', 'ing') - ); + ); $loc_parts_arr = array( - 'loc1' => $loc_parts_arr1 , - 'loc2' => $loc_parts_arr2 , - 'loc3' => $loc_parts_arr3 , - 'loc4' => $loc_parts_arr4 , - 'loc5' => $loc_parts_arr5 , - 'loc6' => $loc_parts_arr6 , - 'loc7' => $loc_parts_arr7 , - 'loc8' => $loc_parts_arr8 , - 'loc9' => $loc_parts_arr9 , - 'loc10' => $loc_parts_arr10 , - 'loc11' => $loc_parts_arr11 , - 'loc12' => $loc_parts_arr12 + 'loc1' => $loc_parts_arr1, + 'loc2' => $loc_parts_arr2, + 'loc3' => $loc_parts_arr3, + 'loc4' => $loc_parts_arr4, + 'loc5' => $loc_parts_arr5, + 'loc6' => $loc_parts_arr6, + 'loc7' => $loc_parts_arr7, + 'loc8' => $loc_parts_arr8, + 'loc9' => $loc_parts_arr9, ); $cnt = 0; $res_str = ''; - foreach($loc_parts_arr as $key => $value ){ + foreach ($loc_parts_arr as $key => $value) { $res_str .= "\n------------"; $res_str .= "\nInput Array name is : loc".(++$cnt) ; -/* - foreach($value as $valKey => $valValue ){ - $res_str .= $valKey ."->".$valValue." " ; - } -*/ - try { - $locale = ut_loc_locale_compose( $value); - $res_str .= "\n\nComposed Locale: "; - if( $locale){ - $res_str .= "$locale"; - }else{ - $res_str .= "No values found from Locale compose due to the following error:\n"; - $res_str .= intl_get_error_message() ; - } - } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + + $locale = ut_loc_locale_compose( $value); + $res_str .= "\n\nComposed Locale: "; + if ($locale) { + $res_str .= "$locale"; + } else { + $res_str .= "No values found from Locale compose due to the following error:\n"; + $res_str .= intl_get_error_message() ; } } @@ -136,9 +110,6 @@ ut_run(); ?> --EXPECT-- -Locale::composeLocale(): Argument #1 ($subtags) must contain a "language" key -locale_compose(): Argument #1 ($subtags) must contain a "language" key - ------------ Input Array name is : loc1 @@ -173,18 +144,6 @@ Input Array name is : loc8 Composed Locale: en_lng_ing_Hans_CN_nedis_rozaj_x_prv1_prv2 ------------ Input Array name is : loc9 ------------- -Input Array name is : loc10 - -Composed Locale: No values found from Locale compose due to the following error: -locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR ------------- -Input Array name is : loc11 - -Composed Locale: No values found from Locale compose due to the following error: -locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR ------------- -Input Array name is : loc12 Composed Locale: en_lng_ing_Hans_CN_nedis_rozaj_x_prv1_prv2 ------------ diff --git a/ext/intl/tests/locale_compose_locale_errors.phpt b/ext/intl/tests/locale_compose_locale_errors.phpt new file mode 100644 index 0000000000000..2188738288052 --- /dev/null +++ b/ext/intl/tests/locale_compose_locale_errors.phpt @@ -0,0 +1,58 @@ +--TEST-- +locale_compose_locale() errors +--EXTENSIONS-- +intl +--FILE-- + 45, + Locale::REGION_TAG => false, + Locale::SCRIPT_TAG => 15, +]; + +var_dump(Locale::composeLocale($parts1)); +var_dump(intl_get_error_message()); +var_dump(locale_compose($parts1)); +var_dump(intl_get_error_message()); + +$parts2 = [ + Locale::LANG_TAG => 'de', + Locale::REGION_TAG => 'DE', + 'private0' => 13, + 'variant1' => array(), + 'extlang2' => false +]; + +var_dump(Locale::composeLocale($parts2)); +var_dump(intl_get_error_message()); +var_dump(locale_compose($parts2)); +var_dump(intl_get_error_message()); + +$parts3 = [ + Locale::REGION_TAG => 'DE', +]; + +try { + var_dump(Locale::composeLocale($parts3)); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump(locale_compose($parts3)); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +bool(false) +string(81) "locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +string(81) "locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +string(81) "locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +string(81) "locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR" +ValueError: Locale::composeLocale(): Argument #1 ($subtags) must contain a "language" key +ValueError: locale_compose(): Argument #1 ($subtags) must contain a "language" key diff --git a/ext/intl/tests/msgfmt_errors.phpt b/ext/intl/tests/msgfmt_errors.phpt new file mode 100644 index 0000000000000..a3f06d4211d53 --- /dev/null +++ b/ext/intl/tests/msgfmt_errors.phpt @@ -0,0 +1,30 @@ +--TEST-- +MessageFormatter with invalid locale +--EXTENSIONS-- +intl +--FILE-- +getMessage(), PHP_EOL; +} + +$mf = MessageFormatter::create('root', $fmt); +var_dump($mf); +var_dump(intl_get_error_message()); + +$mf = msgfmt_create('root', $fmt); +var_dump($mf); +var_dump(intl_get_error_message()); + +?> +--EXPECT-- +IntlException: msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR +NULL +string(74) "msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR" +NULL +string(74) "msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/msgfmt_format.phpt b/ext/intl/tests/msgfmt_format.phpt index 39efaf36c4e31..99440a882e34e 100644 --- a/ext/intl/tests/msgfmt_format.phpt +++ b/ext/intl/tests/msgfmt_format.phpt @@ -17,13 +17,13 @@ function ut_main() 'ru_UA' => "{0,number,integer} мавп на {1,number,integer} деревах це {2,number} мавпи на кожному деревi", 'de' => "{0,number,integer} Affen über {1,number,integer} Bäume um {2,number} Affen pro Baum", 'en_UK' => "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree", - 'root' => '{0,whatever} would not work!', - 'fr' => "C'est la vie!", + 'fr' => "C'est la vie!", ); $str_res = ''; $m = 4560; $t = 123; + $v = [$m, $t, $m/$t]; foreach( $locales as $locale => $pattern ) { @@ -33,8 +33,8 @@ function ut_main() $str_res .= dump(intl_get_error_message())."\n"; continue; } - $str_res .= dump( ut_msgfmt_format( $fmt, array($m, $t, $m/$t) ) ) . "\n"; - $str_res .= dump( ut_msgfmt_format_message($locale, $pattern, array($m, $t, $m/$t))) . "\n"; + $str_res .= dump( ut_msgfmt_format( $fmt, $v) ) . "\n"; + $str_res .= dump( ut_msgfmt_format_message($locale, $pattern, $v)) . "\n"; } return $str_res; } @@ -62,9 +62,6 @@ Locale is: en_UK '4,560 monkeys on 123 trees make 37.073 monkeys per tree' '4,560 monkeys on 123 trees make 37.073 monkeys per tree' -Locale is: root -'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' - Locale is: fr 'C\'est la vie!' 'C\'est la vie!' diff --git a/ext/intl/tests/msgfmt_format_error1.phpt b/ext/intl/tests/msgfmt_format_error1.phpt index aa438fdbb3f83..04f77bd6e5032 100644 --- a/ext/intl/tests/msgfmt_format_error1.phpt +++ b/ext/intl/tests/msgfmt_format_error1.phpt @@ -2,9 +2,10 @@ MessageFormatter::format() insufficient numeric arguments --EXTENSIONS-- intl +--INI-- +intl.use_exceptions=On --FILE-- format(array(7))); +try { + var_dump($mf->format(array(7))); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} ?> ---EXPECTF-- -Warning: MessageFormatter::format(): Inconsistent types declared for an argument in %s on line %d -bool(false) +--EXPECT-- +IntlException: Inconsistent types declared for an argument diff --git a/ext/intl/tests/msgfmt_format_error3.phpt b/ext/intl/tests/msgfmt_format_error3.phpt index f9c44789dc23a..f03beb98ad41c 100644 --- a/ext/intl/tests/msgfmt_format_error3.phpt +++ b/ext/intl/tests/msgfmt_format_error3.phpt @@ -2,17 +2,21 @@ MessageFormatter::format() given negative arg key --EXTENSIONS-- intl +--INI-- +intl.use_exceptions=On --FILE-- format(array("foo" => 7, -1 => "bar"))); +try { + var_dump($mf->format(array("foo" => 7, -1 => "bar"))); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} ?> ---EXPECTF-- -Warning: MessageFormatter::format(): Found negative or too large array key in %s on line %d -bool(false) +--EXPECT-- +IntlException: Found negative or too large array key diff --git a/ext/intl/tests/msgfmt_format_error4.phpt b/ext/intl/tests/msgfmt_format_error4.phpt index a6f5912723087..cfa91dff3f982 100644 --- a/ext/intl/tests/msgfmt_format_error4.phpt +++ b/ext/intl/tests/msgfmt_format_error4.phpt @@ -2,22 +2,32 @@ MessageFormatter::format() invalid UTF-8 for arg key or value --EXTENSIONS-- intl +--INI-- +intl.use_exceptions=On --FILE-- format(array("foo" => 7, "\x80" => "bar"))); +try { + var_dump($mf->format(array("foo" => 7, "\x80" => "bar"))); +} catch (Throwable $e) { + var_dump($e::class === 'IntlException'); + var_dump("Invalid UTF-8 data in argument key: '\x80'" === $e->getMessage()); +} -var_dump($mf->format(array("foo" => "\x80"))); +try { + var_dump($mf->format(array("foo" => "\x80"))); +} catch (Throwable $e) { + var_dump($e::class === 'IntlException'); + var_dump("Invalid UTF-8 data in string argument: '\x80'" === $e->getMessage()); +} ?> ---EXPECTF-- -Warning: MessageFormatter::format(): Invalid UTF-8 data in argument key: '€' in %s on line %d -bool(false) - -Warning: MessageFormatter::format(): Invalid UTF-8 data in string argument: '€' in %s on line %d -bool(false) +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/intl/tests/msgfmt_format_error5.phpt b/ext/intl/tests/msgfmt_format_error5.phpt index f3f87835b9217..f9a64f5ebf088 100644 --- a/ext/intl/tests/msgfmt_format_error5.phpt +++ b/ext/intl/tests/msgfmt_format_error5.phpt @@ -2,21 +2,22 @@ MessageFormatter::format() invalid date/time argument --INI-- date.timezone=Atlantic/Azores +intl.use_exceptions=On --EXTENSIONS-- intl --FILE-- format(array("foo" => new stdclass()))); +try { + var_dump($mf->format(array("foo" => new stdclass()))); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} ?> ---EXPECTF-- -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) +--EXPECT-- +IntlException: The argument for key 'foo' cannot be used as a date or time diff --git a/ext/intl/tests/msgfmt_format_error6.phpt b/ext/intl/tests/msgfmt_format_error6.phpt index 23db397282265..72a748a82fc8e 100644 --- a/ext/intl/tests/msgfmt_format_error6.phpt +++ b/ext/intl/tests/msgfmt_format_error6.phpt @@ -2,17 +2,21 @@ MessageFormatter::format() invalid type for key not in pattern --EXTENSIONS-- intl +--INI-- +intl.use_exceptions=On --FILE-- format(array("foo" => 'bar', 7 => fopen('php://memory', 'r+')))); +try { + var_dump($mf->format(array("foo" => 'bar', 7 => fopen('php://memory', 'r+')))); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} ?> ---EXPECTF-- -Warning: MessageFormatter::format(): No strategy to convert the value given for the argument with key '7' is available in %s on line %d -bool(false) +--EXPECT-- +IntlException: No strategy to convert the value given for the argument with key '7' is available diff --git a/ext/intl/tests/msgfmt_format_message_errors.phpt b/ext/intl/tests/msgfmt_format_message_errors.phpt new file mode 100644 index 0000000000000..f3d6575ab372c --- /dev/null +++ b/ext/intl/tests/msgfmt_format_message_errors.phpt @@ -0,0 +1,27 @@ +--TEST-- +MessageFormatter::parseMessage() with invalid locale +--EXTENSIONS-- +intl +--FILE-- + +--EXPECT-- +bool(false) +string(47) "Creating message formatter failed: U_ZERO_ERROR" +bool(false) +string(47) "Creating message formatter failed: U_ZERO_ERROR" diff --git a/ext/intl/tests/msgfmt_get_set_pattern.phpt b/ext/intl/tests/msgfmt_get_set_pattern.phpt index 4a667b0b0073d..bf34ce6fee555 100644 --- a/ext/intl/tests/msgfmt_get_set_pattern.phpt +++ b/ext/intl/tests/msgfmt_get_set_pattern.phpt @@ -35,10 +35,6 @@ function ut_main() ut_msgfmt_set_pattern($fmt, str_repeat($pattern, 10)); $res_str .= "New pattern: '" . ut_msgfmt_get_pattern( $fmt ) . "'\n"; $res_str .= "Formatted message: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n"; - $res = ut_msgfmt_set_pattern($fmt, "{0,number} trees hosting {1,number monkeys"); - if ($res !== false) die("ut_msgfmt_set_pattern should fail"); - $res_str .= ut_msgfmt_get_error_message( $fmt ) . " (" . ut_msgfmt_get_error_code( $fmt ) . ")\n"; - return $res_str; } @@ -54,4 +50,3 @@ New pattern: '{0,number} trees hosting {1,number} monkeys' Formatted message: 123 trees hosting 456 monkeys New pattern: '{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys' Formatted message: 123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys -Error setting symbol value at line 0, offset 26: U_PATTERN_SYNTAX_ERROR (65799) diff --git a/ext/intl/tests/msgfmt_parse.phpt b/ext/intl/tests/msgfmt_parse.phpt index ce14c6ff41dd2..0134f6d1247b1 100644 --- a/ext/intl/tests/msgfmt_parse.phpt +++ b/ext/intl/tests/msgfmt_parse.phpt @@ -17,8 +17,7 @@ function ut_main() 'ru_UA' => "{0,number,integer} мавп на {1,number,integer} деревах це {2,number} мавпи на кожному деревi", 'de' => "{0,number,integer} Affen über {1,number,integer} Bäume um {2,number} Affen pro Baum", 'en_UK' => "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree", - 'root' => '{0,whatever} would not work!', - 'fr' => 'C\'est {0,number,integer}', + 'fr' => 'C\'est {0,number,integer}', ); $results = array( @@ -26,7 +25,6 @@ function ut_main() 'ru_UA' => "4 560 мавп на 123 деревах це 37,073 мавпи на кожному деревi", 'de' => "4.560 Affen über 123 Bäume um 37,073 Affen pro Baum", 'en_UK' => "4,560 monkeys on 123 trees make 37.073 monkeys per tree", - 'root' => "4,560 monkeys on 123 trees make 37.073 monkeys per tree", 'fr' => "C'est 42", ); @@ -102,9 +100,6 @@ array ( 2 => 37.073, ) -Locale is: root -'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' - Locale is: fr array ( 0 => 42, diff --git a/ext/intl/tests/gh19261.phpt b/ext/intl/tests/msgfmt_parse_message_errors.phpt similarity index 89% rename from ext/intl/tests/gh19261.phpt rename to ext/intl/tests/msgfmt_parse_message_errors.phpt index 3f281919a9562..9402b8e2b5418 100644 --- a/ext/intl/tests/gh19261.phpt +++ b/ext/intl/tests/msgfmt_parse_message_errors.phpt @@ -9,8 +9,7 @@ girgias@php.net $locale = 'root'; $fmt = '{0,whatever} would not work!'; - -$str = 'failing'; +$str = '4,560 monkeys on 123 trees make 37.073 monkeys per tree'; $m = MessageFormatter::parseMessage($locale, $fmt, $str); var_dump($m); diff --git a/ext/intl/tests/msgfmt_set_pattern_syntax_error.phpt b/ext/intl/tests/msgfmt_set_pattern_syntax_error.phpt new file mode 100644 index 0000000000000..c53cf43f748c3 --- /dev/null +++ b/ext/intl/tests/msgfmt_set_pattern_syntax_error.phpt @@ -0,0 +1,22 @@ +--TEST-- +msgfmt_set_pattern() with syntax error +--EXTENSIONS-- +intl +--FILE-- +setPattern($broken); +var_dump($mf->getErrorMessage()); + +msgfmt_set_pattern($mf, $broken); +var_dump($mf->getErrorMessage()); + +?> +--EXPECT-- +string(71) "Error setting symbol value at line 0, offset 26: U_PATTERN_SYNTAX_ERROR" +string(71) "Error setting symbol value at line 0, offset 26: U_PATTERN_SYNTAX_ERROR" diff --git a/ext/intl/tests/normalizer_get_raw_decomposition.phpt b/ext/intl/tests/normalizer_get_raw_decomposition.phpt index efb4424c80c97..7085cfa4a7ec7 100644 --- a/ext/intl/tests/normalizer_get_raw_decomposition.phpt +++ b/ext/intl/tests/normalizer_get_raw_decomposition.phpt @@ -2,67 +2,52 @@ normalizer_get_raw_decomposition() --EXTENSIONS-- intl ---SKIPIF-- - --FILE-- --EXPECT-- ---------------------- -'61' has no decomposition mapping -error info: 'U_ZERO_ERROR' (0) ---------------------- -'efbf9a' has the decomposition mapping 'e385a1' -error info: 'U_ZERO_ERROR' (0) ---------------------- -'efb7ba' has the decomposition mapping 'd8b5d984d98920d8a7d984d984d98720d8b9d984d98ad98720d988d8b3d984d985' -error info: 'U_ZERO_ERROR' (0) ---------------------- -'' has no decomposition mapping -error info: 'Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR' (1) ---------------------- -'6161' has no decomposition mapping -error info: 'Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR' (1) ---------------------- -'f5' has no decomposition mapping -error info: 'Code point out of range: U_ILLEGAL_ARGUMENT_ERROR' (1) +'a' has no decomposition mapping +'a' has no decomposition mapping +string(3) "ã…¡" +string(3) "ã…¡" +string(33) "صلى الله عليه وسلم" +string(33) "صلى الله عليه وسلم" +string(89) "Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR" +string(89) "Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR" +string(89) "Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR" +string(89) "Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR" +string(49) "Code point out of range: U_ILLEGAL_ARGUMENT_ERROR" +string(49) "Code point out of range: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/resourcebundle_create.phpt b/ext/intl/tests/resourcebundle_create.phpt index 819d31b85a12f..81c889a2d0fe7 100644 --- a/ext/intl/tests/resourcebundle_create.phpt +++ b/ext/intl/tests/resourcebundle_create.phpt @@ -24,14 +24,6 @@ function ut_main() { $str_res .= debug( $r1 ); $str_res .= print_r( $r1['testsring'], true); - // fall out - $r2 = ut_resourcebundle_create( 'en_US', BUNDLE, false ); - $str_res .= debug( $r2 ); - - // missing - $r3 = ut_resourcebundle_create( 'en_US', 'nonexisting' ); - $str_res .= debug( $r3 ); - return $str_res; } @@ -56,7 +48,3 @@ ResourceBundle Object ) -127: U_USING_DEFAULT_WARNING -NULL - 2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR -NULL - 2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR diff --git a/ext/intl/tests/resourcebundle_create_error.phpt b/ext/intl/tests/resourcebundle_create_error.phpt new file mode 100644 index 0000000000000..92e08313df260 --- /dev/null +++ b/ext/intl/tests/resourcebundle_create_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +ResourceBundle creation errors +--EXTENSIONS-- +intl +--FILE-- +getMessage(), PHP_EOL; +} + +$rb = resourcebundle_create('en_US', 'non-existing'); +var_dump($rb); +var_dump(intl_get_error_message()); + +require_once "resourcebundle.inc"; + +try { + $rb = new ResourceBundle('en_US', BUNDLE, false); + var_dump($rb); + var_dump(intl_get_error_message()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +$rb = resourcebundle_create('en_US', BUNDLE, false); +var_dump($rb); +var_dump(intl_get_error_message()); + +?> +--EXPECT-- +IntlException: Constructor failed +NULL +string(81) "resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR" +IntlException: Constructor failed +NULL +string(81) "resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR" diff --git a/ext/intl/tests/resourcebundle_get_errors.phpt b/ext/intl/tests/resourcebundle_get_errors.phpt new file mode 100644 index 0000000000000..aaae32a1bcd68 --- /dev/null +++ b/ext/intl/tests/resourcebundle_get_errors.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test ResourceBundle::get() missing keys +--EXTENSIONS-- +intl +--FILE-- +get('nonexisting')); +var_dump(intl_get_error_message()); + +var_dump(resourcebundle_get($bundle, 'nonexisting')); +var_dump(intl_get_error_message()); + +// Make sure accessing existing after non-existing works. +var_dump($bundle->get('teststring')); + +?> +--EXPECT-- +NULL +string(68) "Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR" +NULL +string(68) "Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR" +string(12) "Hello World!" diff --git a/ext/intl/tests/resourcebundle_individual.phpt b/ext/intl/tests/resourcebundle_individual.phpt index d9be94b464b1b..089c485dc8ab3 100644 --- a/ext/intl/tests/resourcebundle_individual.phpt +++ b/ext/intl/tests/resourcebundle_individual.phpt @@ -1,5 +1,5 @@ --TEST-- -Test ResourceBundle::get() and length() - existing/missing keys +Test ResourceBundle::get() and length() - existing keys --EXTENSIONS-- intl --FILE-- @@ -25,13 +25,6 @@ function ut_main() { $r2 = ut_resourcebundle_get($r,'testarray' ); $str_res .= sprintf( "testarray: %s\n", ut_resourcebundle_get($r2, 2 ) ); - $t = ut_resourcebundle_get( $r, 'nonexisting' ); - $str_res .= debug( $t ); - - // Make sure accessing existing after non-existing works. - $t = ut_resourcebundle_get( $r, 'teststring' ); - $str_res .= debug( $t ); - return $str_res; } include_once( 'ut_common.inc' ); @@ -57,7 +50,3 @@ Array testbin: a1b2c3d4e5f67890 testtable: 3 testarray: string 3 -NULL - 2: Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR -Hello World! - 0: U_ZERO_ERROR diff --git a/ext/intl/tests/timezone_IDforWindowsID_basic.phpt b/ext/intl/tests/timezone_IDforWindowsID_basic.phpt index 8626223cb8bb4..8e1fcbb4a8fc3 100644 --- a/ext/intl/tests/timezone_IDforWindowsID_basic.phpt +++ b/ext/intl/tests/timezone_IDforWindowsID_basic.phpt @@ -8,7 +8,6 @@ intl 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'), @@ -25,9 +24,6 @@ foreach ($tzs as $tz => $regions) { } ?> --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 diff --git a/ext/intl/tests/timezone_IDforWindowsID_basic2.phpt b/ext/intl/tests/timezone_IDforWindowsID_basic_icu58_1.phpt similarity index 91% rename from ext/intl/tests/timezone_IDforWindowsID_basic2.phpt rename to ext/intl/tests/timezone_IDforWindowsID_basic_icu58_1.phpt index 600e21fa70c80..b92ebb89ec207 100644 --- a/ext/intl/tests/timezone_IDforWindowsID_basic2.phpt +++ b/ext/intl/tests/timezone_IDforWindowsID_basic_icu58_1.phpt @@ -9,7 +9,6 @@ intl 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'), @@ -26,9 +25,6 @@ foreach ($tzs as $tz => $regions) { } ?> --EXPECTF-- -** Gnomeregan -bool(false) -Error: unknown windows timezone: U_ILLEGAL_ARGUMENT_ERROR ** India Standard Time string(13) "Asia/Calcutta" ** Pacific Standard Time diff --git a/ext/intl/tests/timezone_IDforWindowsID_basic_icu76_1.phpt b/ext/intl/tests/timezone_IDforWindowsID_basic_icu76_1.phpt index 96de341974b1a..d07c14797c654 100644 --- a/ext/intl/tests/timezone_IDforWindowsID_basic_icu76_1.phpt +++ b/ext/intl/tests/timezone_IDforWindowsID_basic_icu76_1.phpt @@ -8,7 +8,6 @@ intl 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'), @@ -24,10 +23,7 @@ foreach ($tzs as $tz => $regions) { } } ?> ---EXPECTF-- -** Gnomeregan -bool(false) -Error: %snknown windows timezone: U_ILLEGAL_ARGUMENT_ERROR +--EXPECT-- ** India Standard Time string(13) "Asia/Calcutta" ** Pacific Standard Time diff --git a/ext/intl/tests/timezone_IDforWindowsID_error.phpt b/ext/intl/tests/timezone_IDforWindowsID_error.phpt new file mode 100644 index 0000000000000..f25f7b99e8626 --- /dev/null +++ b/ext/intl/tests/timezone_IDforWindowsID_error.phpt @@ -0,0 +1,14 @@ +--TEST-- +IntlTimeZone::getIDForWindowsID() errors +--EXTENSIONS-- +intl +--FILE-- + +--EXPECT-- +bool(false) +string(50) "unknown windows timezone: U_ILLEGAL_ARGUMENT_ERROR"