summaryrefslogtreecommitdiff
path: root/ext/intl/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/intl/tests')
-rw-r--r--ext/intl/tests/breakiter___construct_error.phpt56
-rw-r--r--ext/intl/tests/bug62017.phpt14
-rw-r--r--ext/intl/tests/bug62081.phpt7
-rw-r--r--ext/intl/tests/dateformat___construct_bad_tz_cal.phpt35
-rw-r--r--ext/intl/tests/dateformat_calendars.phpt7
-rw-r--r--ext/intl/tests/dateformat_calendars_variant2.phpt7
-rw-r--r--ext/intl/tests/formatter_fail.phpt28
-rw-r--r--ext/intl/tests/gregoriancalendar___construct_error.phpt26
-rw-r--r--ext/intl/tests/msgfmt_fail.phpt43
-rw-r--r--ext/intl/tests/msgfmt_fail2.phpt43
-rw-r--r--ext/intl/tests/ut_common.inc20
11 files changed, 209 insertions, 77 deletions
diff --git a/ext/intl/tests/breakiter___construct_error.phpt b/ext/intl/tests/breakiter___construct_error.phpt
index 770f1403c7..bea65667fa 100644
--- a/ext/intl/tests/breakiter___construct_error.phpt
+++ b/ext/intl/tests/breakiter___construct_error.phpt
@@ -7,32 +7,44 @@ IntlRuleBasedBreakIterator::__construct(): arg errors
<?php
ini_set("intl.error_level", E_WARNING);
-//missing ; at the end:
-var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+'));
-var_dump(new IntlRuleBasedBreakIterator());
-var_dump(new IntlRuleBasedBreakIterator(1,2,3));
-var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', array()));
-var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', true));
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+//missing ; at the end:
+try {
+ var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+'));
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlRuleBasedBreakIterator());
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlRuleBasedBreakIterator(1,2,3));
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', array()));
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', true));
+} catch (IntlException $e) {
+ print_exception($e);
+}
--EXPECTF--
-Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d
-NULL
-
-Warning: IntlRuleBasedBreakIterator::__construct() expects at least 1 parameter, 0 given in %s on line %d
-
-Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: bad arguments in %s on line %d
-NULL
-
-Warning: IntlRuleBasedBreakIterator::__construct() expects at most 2 parameters, 3 given in %s on line %d
+Exception: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d
-Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: bad arguments in %s on line %d
-NULL
+Exception: IntlRuleBasedBreakIterator::__construct() expects at least 1 parameter, 0 given in %s on line %d
-Warning: IntlRuleBasedBreakIterator::__construct() expects parameter 2 to be boolean, array given in %s on line %d
+Exception: IntlRuleBasedBreakIterator::__construct() expects at most 2 parameters, 3 given in %s on line %d
-Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: bad arguments in %s on line %d
-NULL
+Exception: IntlRuleBasedBreakIterator::__construct() expects parameter 2 to be boolean, array given in %s on line %d
-Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create instance from compiled rules in %s on line %d
-NULL
+Exception: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create instance from compiled rules in %s on line %d
diff --git a/ext/intl/tests/bug62017.phpt b/ext/intl/tests/bug62017.phpt
index 50aeae4806..2f3c816f99 100644
--- a/ext/intl/tests/bug62017.phpt
+++ b/ext/intl/tests/bug62017.phpt
@@ -10,13 +10,15 @@ ini_set('intl.error_level', E_WARNING);
var_dump(
datefmt_create('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "\xFF",
IntlDateFormatter::GREGORIAN, 'a'));
-var_dump(
- new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon",
- IntlDateFormatter::GREGORIAN, "\x80"));
+try {
+ var_dump(
+ new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon",
+ IntlDateFormatter::GREGORIAN, "\x80"));
+} catch (IntlException $e) {
+ echo PHP_EOL."Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . PHP_EOL;
+}
--EXPECTF--
Warning: datefmt_create(): datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d
NULL
-Warning: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %s on line %d
-NULL
-
+Exception: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %sbug62017.php on line %d
diff --git a/ext/intl/tests/bug62081.phpt b/ext/intl/tests/bug62081.phpt
index 44ad4beec7..263023ffac 100644
--- a/ext/intl/tests/bug62081.phpt
+++ b/ext/intl/tests/bug62081.phpt
@@ -12,5 +12,8 @@ ini_set('intl.error_level', E_WARNING);
$x = new IntlDateFormatter('en', 1, 1);
var_dump($x->__construct('en', 1, 1));
--EXPECTF--
-Warning: IntlDateFormatter::__construct(): datefmt_create: cannot call constructor twice in %s on line %d
-NULL
+Fatal error: Uncaught exception 'IntlException' with message 'IntlDateFormatter::__construct(): datefmt_create: cannot call constructor twice' in %sbug62081.php:4
+Stack trace:
+#0 %sbug62081.php(4): IntlDateFormatter->__construct('en', 1, 1)
+#1 {main}
+ thrown in %sbug62081.php on line 4
diff --git a/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt
index cfd9338717..d10ad42623 100644
--- a/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt
+++ b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt
@@ -10,23 +10,32 @@ ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
ini_set("date.timezone", 'Atlantic/Azores');
-var_dump(new IntlDateFormatter(NULL, 0, 0, 'bad timezone'));
-
-var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, 3));
-
-var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, new stdclass));
-
-
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+
+try {
+ var_dump(new IntlDateFormatter(NULL, 0, 0, 'bad timezone'));
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, 3));
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, new stdclass));
+} catch (IntlException $e) {
+ print_exception($e);
+}
?>
==DONE==
--EXPECTF--
-Warning: IntlDateFormatter::__construct(): datefmt_create: no such time zone: 'bad timezone' in %s on line %d
-NULL
+Exception: IntlDateFormatter::__construct(): datefmt_create: no such time zone: 'bad timezone' in %s on line %d
-Warning: 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 on line %d
-NULL
+Exception: 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 on line %d
-Warning: IntlDateFormatter::__construct(): datefmt_create: Invalid calendar argument; should be an integer or an IntlCalendar instance in %s on line %d
-NULL
+Exception: IntlDateFormatter::__construct(): datefmt_create: Invalid calendar argument; should be an integer or an IntlCalendar instance in %s on line %d
==DONE==
diff --git a/ext/intl/tests/dateformat_calendars.phpt b/ext/intl/tests/dateformat_calendars.phpt
index 7de6356455..13dde0f370 100644
--- a/ext/intl/tests/dateformat_calendars.phpt
+++ b/ext/intl/tests/dateformat_calendars.phpt
@@ -41,5 +41,8 @@ string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12"
string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12"
string(42) "Sunday, Tevet 6, 5772 5:12:00 AM GMT+05:12"
-Warning: 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 on line %d
-==DONE==
+Fatal error: Uncaught exception 'IntlException' with message '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.php:%d
+Stack trace:
+#0 %sdateformat_calendars.php(%d): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1)
+#1 {main}
+ thrown in %sdateformat_calendars.php on line %d
diff --git a/ext/intl/tests/dateformat_calendars_variant2.phpt b/ext/intl/tests/dateformat_calendars_variant2.phpt
index b3b1701c55..11a5026da0 100644
--- a/ext/intl/tests/dateformat_calendars_variant2.phpt
+++ b/ext/intl/tests/dateformat_calendars_variant2.phpt
@@ -42,5 +42,8 @@ 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(48) "Sunday, Tevet 6, 5772 AM at 5:12:00 AM GMT+05:12"
-Warning: 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_variant2.php on line %d
-==DONE==
+Fatal error: Uncaught exception 'IntlException' with message '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_variant2.php:27
+Stack trace:
+#0 %sdateformat_calendars_variant2.php(27): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1)
+#1 {main}
+ thrown in %sdateformat_calendars_variant2.php on line 27
diff --git a/ext/intl/tests/formatter_fail.phpt b/ext/intl/tests/formatter_fail.phpt
index 295f011008..f61cb14878 100644
--- a/ext/intl/tests/formatter_fail.phpt
+++ b/ext/intl/tests/formatter_fail.phpt
@@ -11,10 +11,19 @@ function err($fmt) {
}
}
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+
function crt($t, $l, $s) {
switch(true) {
case $t == "O":
- return new NumberFormatter($l, $s);
+ try {
+ return new NumberFormatter($l, $s);
+ } catch (IntlException $e) {
+ print_exception($e);
+ return null;
+ }
break;
case $t == "C":
return NumberFormatter::create($l, $s);
@@ -33,7 +42,12 @@ $args = array(
array("en_US", NumberFormatter::PATTERN_RULEBASED),
);
-$fmt = new NumberFormatter();
+try {
+ $fmt = new NumberFormatter();
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
+}
err($fmt);
$fmt = numfmt_create();
err($fmt);
@@ -51,7 +65,7 @@ foreach($args as $arg) {
?>
--EXPECTF--
-Warning: NumberFormatter::__construct() expects at least 2 parameters, 0 given in %s on line %d
+Exception: 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
@@ -59,11 +73,13 @@ Warning: numfmt_create() expects at least 2 parameters, 0 given in %s on line %d
Warning: NumberFormatter::create() expects at least 2 parameters, 0 given in %s on line %d
'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %sformatter_fail.php on line %d
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
-Warning: NumberFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
+Exception: NumberFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: NumberFormatter::create() expects parameter 1 to be string, array given in %s on line %d
@@ -71,9 +87,13 @@ Warning: NumberFormatter::create() expects parameter 1 to be string, array given
Warning: numfmt_create() expects parameter 1 to be string, array given in %s on line %d
'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %sformatter_fail.php on line %d
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
+
+Exception: Constructor failed in %sformatter_fail.php on line %d
'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
diff --git a/ext/intl/tests/gregoriancalendar___construct_error.phpt b/ext/intl/tests/gregoriancalendar___construct_error.phpt
index 45229cf000..d81809793e 100644
--- a/ext/intl/tests/gregoriancalendar___construct_error.phpt
+++ b/ext/intl/tests/gregoriancalendar___construct_error.phpt
@@ -8,13 +8,23 @@ if (!extension_loaded('intl'))
<?php
ini_set("intl.error_level", E_WARNING);
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+
var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7));
var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7,8));
var_dump(intlgregcal_create_instance(1,2,3,4));
-var_dump(new IntlGregorianCalendar(1,2,NULL,4));
-var_dump(new IntlGregorianCalendar(1,2,3,4,NULL,array()));
-
-
+try {
+ var_dump(new IntlGregorianCalendar(1,2,NULL,4));
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlGregorianCalendar(1,2,3,4,NULL,array()));
+} catch (IntlException $e) {
+ print_exception($e);
+}
--EXPECTF--
Warning: intlgregcal_create_instance(): intlgregcal_create_instance: too many arguments in %s on line %d
@@ -26,10 +36,6 @@ NULL
Warning: intlgregcal_create_instance(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
NULL
-Warning: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
-NULL
-
-Warning: IntlGregorianCalendar::__construct() expects parameter 6 to be integer, array given in %s on line %d
+Exception: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
-Warning: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: bad arguments in %s on line %d
-NULL
+Exception: IntlGregorianCalendar::__construct() expects parameter 6 to be integer, array given in %s on line %d
diff --git a/ext/intl/tests/msgfmt_fail.phpt b/ext/intl/tests/msgfmt_fail.phpt
index bffb71c56d..7c76598c0d 100644
--- a/ext/intl/tests/msgfmt_fail.phpt
+++ b/ext/intl/tests/msgfmt_fail.phpt
@@ -12,10 +12,19 @@ function err($fmt) {
}
}
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+
function crt($t, $l, $s) {
switch(true) {
case $t == "O":
- return new MessageFormatter($l, $s);
+ try {
+ return new MessageFormatter($l, $s);
+ } catch (IntlException $e) {
+ print_exception($e);
+ return null;
+ }
break;
case $t == "C":
return MessageFormatter::create($l, $s);
@@ -35,13 +44,23 @@ $args = array(
array("en_US", "\xD0"),
);
-$fmt = new MessageFormatter();
+try {
+ $fmt = new MessageFormatter();
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
+}
err($fmt);
$fmt = msgfmt_create();
err($fmt);
$fmt = MessageFormatter::create();
-err($fmt);
-$fmt = new MessageFormatter('en');
+err($fmt);
+try {
+ $fmt = new MessageFormatter('en');
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
+}
err($fmt);
$fmt = msgfmt_create('en');
err($fmt);
@@ -59,7 +78,7 @@ foreach($args as $arg) {
?>
--EXPECTF--
-Warning: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d
+Exception: 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
@@ -68,7 +87,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'
-Warning: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d
+Exception: 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
@@ -76,14 +95,18 @@ Warning: msgfmt_create() expects exactly 2 parameters, 1 given in %s on line %d
Warning: MessageFormatter::create() expects exactly 2 parameters, 1 given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
-Warning: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
+Exception: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: MessageFormatter::create() expects parameter 1 to be string, array given in %s on line %d
@@ -91,12 +114,18 @@ Warning: MessageFormatter::create() expects parameter 1 to be string, array give
Warning: msgfmt_create() expects parameter 1 to be string, array given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
diff --git a/ext/intl/tests/msgfmt_fail2.phpt b/ext/intl/tests/msgfmt_fail2.phpt
index eee2424a50..0ab99cf633 100644
--- a/ext/intl/tests/msgfmt_fail2.phpt
+++ b/ext/intl/tests/msgfmt_fail2.phpt
@@ -12,10 +12,19 @@ function err($fmt) {
}
}
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+
function crt($t, $l, $s) {
switch(true) {
case $t == "O":
- return new MessageFormatter($l, $s);
+ try {
+ return new MessageFormatter($l, $s);
+ } catch (IntlException $e) {
+ print_exception($e);
+ return null;
+ }
break;
case $t == "C":
return MessageFormatter::create($l, $s);
@@ -35,13 +44,23 @@ $args = array(
array("en_US", "\xD0"),
);
-$fmt = new MessageFormatter();
+try {
+ $fmt = new MessageFormatter();
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
+}
err($fmt);
$fmt = msgfmt_create();
err($fmt);
$fmt = MessageFormatter::create();
-err($fmt);
-$fmt = new MessageFormatter('en');
+err($fmt);
+try {
+ $fmt = new MessageFormatter('en');
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
+}
err($fmt);
$fmt = msgfmt_create('en');
err($fmt);
@@ -59,7 +78,7 @@ foreach($args as $arg) {
?>
--EXPECTF--
-Warning: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d
+Exception: 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
@@ -68,7 +87,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'
-Warning: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d
+Exception: 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
@@ -76,14 +95,18 @@ Warning: msgfmt_create() expects exactly 2 parameters, 1 given in %s on line %d
Warning: MessageFormatter::create() expects exactly 2 parameters, 1 given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
-Warning: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
+Exception: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: MessageFormatter::create() expects parameter 1 to be string, array given in %s on line %d
@@ -91,12 +114,18 @@ Warning: MessageFormatter::create() expects parameter 1 to be string, array give
Warning: msgfmt_create() expects parameter 1 to be string, array given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR'
'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR'
'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
diff --git a/ext/intl/tests/ut_common.inc b/ext/intl/tests/ut_common.inc
index 09be22bf5a..9f72bacae4 100644
--- a/ext/intl/tests/ut_common.inc
+++ b/ext/intl/tests/ut_common.inc
@@ -132,7 +132,15 @@ function ut_coll_set_default( $coll )
function ut_nfmt_create( $locale, $style, $pattern = null )
{
- return $GLOBALS['oo-mode'] ? new NumberFormatter( $locale, $style, $pattern ) : numfmt_create( $locale, $style, $pattern );
+ if ($GLOBALS['oo-mode']) {
+ try {
+ return new NumberFormatter( $locale, $style, $pattern );
+ } catch (Exception $e) {
+ return NULL;
+ }
+ } else {
+ return numfmt_create( $locale, $style, $pattern );
+ }
}
function ut_nfmt_format( $fmt, $number, $type = null )
{
@@ -392,7 +400,15 @@ function ut_datefmt_localtime( $fmt , $value , &$parse_pos=0 )
function ut_resourcebundle_create( $locale, $bundle, $fallback=true )
{
- return $GLOBALS['oo-mode'] ? new ResourceBundle($locale, $bundle, $fallback): resourcebundle_create($locale, $bundle, $fallback);
+ if ($GLOBALS['oo-mode']) {
+ try {
+ return new ResourceBundle($locale, $bundle, $fallback);
+ } catch (Exception $e) {
+ return NULL;
+ }
+ } else {
+ return resourcebundle_create($locale, $bundle, $fallback);
+ }
}
function ut_resourcebundle_count($bundle )
{