summaryrefslogtreecommitdiff
path: root/ext/intl/tests
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-03-30 18:53:38 +0300
committerDmitry Stogov <dmitry@zend.com>2015-03-30 18:53:38 +0300
commit1018f462d8bb0a12b238d9d11c141038beaf2a6c (patch)
tree6466aa51c3924c5ed56741e02fa323fcb3e2ece4 /ext/intl/tests
parent9155a267adeeb6f442f97892de441e4b6666ce73 (diff)
downloadphp-git-1018f462d8bb0a12b238d9d11c141038beaf2a6c.tar.gz
Patch improvement:
Removed the corresponding core code. Fixed ext/com_dotnet and ext/date. Refactored ext/intl changes. Improved ext/fileinfo and ext/pdo changes. Fixed tests.
Diffstat (limited to 'ext/intl/tests')
-rw-r--r--ext/intl/tests/breakiter___construct_error.phpt56
-rw-r--r--ext/intl/tests/bug62017.phpt12
-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_variant2.phpt7
-rw-r--r--ext/intl/tests/formatter_fail.phpt71
-rw-r--r--ext/intl/tests/formatter_format.phpt9
-rw-r--r--ext/intl/tests/gregoriancalendar___construct_error.phpt26
-rw-r--r--ext/intl/tests/msgfmt_fail.phpt78
-rw-r--r--ext/intl/tests/msgfmt_fail2.phpt43
-rw-r--r--ext/intl/tests/msgfmt_parse.phpt14
-rw-r--r--ext/intl/tests/resourcebundle_create.phpt29
-rw-r--r--ext/intl/tests/ut_common.inc20
13 files changed, 244 insertions, 163 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 e5c216c1e2..2f3c816f99 100644
--- a/ext/intl/tests/bug62017.phpt
+++ b/ext/intl/tests/bug62017.phpt
@@ -11,14 +11,14 @@ var_dump(
datefmt_create('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "\xFF",
IntlDateFormatter::GREGORIAN, 'a'));
try {
- new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon",
- IntlDateFormatter::GREGORIAN, "\x80");
-}
-catch(IntlException $ie) {
- echo $ie->getMessage().PHP_EOL;
+ 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
-datefmt_create: error converting pattern to UTF-16
+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_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 c45b113bdb..f61cb14878 100644
--- a/ext/intl/tests/formatter_fail.phpt
+++ b/ext/intl/tests/formatter_fail.phpt
@@ -11,24 +11,26 @@ function err($fmt) {
}
}
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+
function crt($t, $l, $s) {
- try {
- $fmt = null;
- switch(true) {
- case $t == "O":
- $fmt = new NumberFormatter($l, $s);
- break;
- case $t == "C":
- $fmt = NumberFormatter::create($l, $s);
- break;
- case $t == "P":
- $fmt = numfmt_create($l, $s);
- break;
- }
- err($fmt);
- }
- catch(IntlException $ie) {
- echo "IE: ".$ie->getMessage().PHP_EOL;
+ switch(true) {
+ case $t == "O":
+ try {
+ return new NumberFormatter($l, $s);
+ } catch (IntlException $e) {
+ print_exception($e);
+ return null;
+ }
+ break;
+ case $t == "C":
+ return NumberFormatter::create($l, $s);
+ break;
+ case $t == "P":
+ return numfmt_create($l, $s);
+ break;
}
}
@@ -42,11 +44,11 @@ $args = array(
try {
$fmt = new NumberFormatter();
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
}
-catch(IntlException $ie) {
- echo $ie->getMessage().PHP_EOL;
-}
-
+err($fmt);
$fmt = numfmt_create();
err($fmt);
$fmt = NumberFormatter::create();
@@ -54,13 +56,16 @@ err($fmt);
foreach($args as $arg) {
$fmt = crt("O", $arg[0], $arg[1]);
+ err($fmt);
$fmt = crt("C", $arg[0], $arg[1]);
+ err($fmt);
$fmt = crt("P", $arg[0], $arg[1]);
+ err($fmt);
}
?>
--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
@@ -68,21 +73,27 @@ 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
'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: numfmt_create() expects parameter 1 to be string, array given in %s on line %d
-IE: numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR
-IE: numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR
-IE: numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR
-IE: numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR
-IE: numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR
-IE: numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR
-IE: numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR
+'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/formatter_format.phpt b/ext/intl/tests/formatter_format.phpt
index 0fa88681d9..334ef49567 100644
--- a/ext/intl/tests/formatter_format.phpt
+++ b/ext/intl/tests/formatter_format.phpt
@@ -50,14 +50,7 @@ function ut_main()
$str_res .= "\nLocale is: $locale\n";
foreach( $styles as $style => $pattern )
{
- try {
- $fmt = ut_nfmt_create( $locale, $style, $pattern );
- }
- catch (IntlException $ie) {
- //$str_res .= "IE:".$ie->getMessage()."\n";
- $str_res .= "Bad formatter!\n";
- continue;
- }
+ $fmt = ut_nfmt_create( $locale, $style, $pattern );
if(!$fmt) {
$str_res .= "Bad formatter!\n";
diff --git a/ext/intl/tests/gregoriancalendar___construct_error.phpt b/ext/intl/tests/gregoriancalendar___construct_error.phpt
index a28fa715e4..d81809793e 100644
--- a/ext/intl/tests/gregoriancalendar___construct_error.phpt
+++ b/ext/intl/tests/gregoriancalendar___construct_error.phpt
@@ -8,23 +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));
try {
- new IntlGregorianCalendar(1,2,NULL,4);
-}
-catch (IntlException $ie) {
- echo "IE: ".$ie->getMessage().PHP_EOL;
+ var_dump(new IntlGregorianCalendar(1,2,NULL,4));
+} catch (IntlException $e) {
+ print_exception($e);
}
try {
- new IntlGregorianCalendar(1,2,3,4,NULL,array());
-}
-catch (IntlException $ie) {
- echo "IE: ".$ie->getMessage().PHP_EOL;
+ 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
@@ -36,6 +36,6 @@ NULL
Warning: intlgregcal_create_instance(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
NULL
-IE: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs)
-Warning: IntlGregorianCalendar::__construct() expects parameter 6 to be integer, array given in %s on line %d
-IE: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: bad arguments
+Exception: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
+
+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 4b60b35abc..7c76598c0d 100644
--- a/ext/intl/tests/msgfmt_fail.phpt
+++ b/ext/intl/tests/msgfmt_fail.phpt
@@ -12,25 +12,26 @@ function err($fmt) {
}
}
-function crt($t, $l, $s) {
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
- try {
- $fmt = null;
- switch(true) {
- case $t == "O":
- $fmt = new MessageFormatter($l, $s);
- break;
- case $t == "C":
- $fmt = MessageFormatter::create($l, $s);
- break;
- case $t == "P":
- $fmt = msgfmt_create($l, $s);
- break;
- }
- err($fmt);
- }
- catch (IntlException $ie) {
- echo "IE: ".$ie->getMessage().PHP_EOL;
+function crt($t, $l, $s) {
+ switch(true) {
+ case $t == "O":
+ try {
+ return new MessageFormatter($l, $s);
+ } catch (IntlException $e) {
+ print_exception($e);
+ return null;
+ }
+ break;
+ case $t == "C":
+ return MessageFormatter::create($l, $s);
+ break;
+ case $t == "P":
+ return msgfmt_create($l, $s);
+ break;
}
}
@@ -45,34 +46,40 @@ $args = array(
try {
$fmt = new MessageFormatter();
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
}
-catch(IntlException $ie) {
- echo "IE: ".$ie->getMessage().PHP_EOL;
-}
+err($fmt);
$fmt = msgfmt_create();
err($fmt);
$fmt = MessageFormatter::create();
err($fmt);
try {
$fmt = new MessageFormatter('en');
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
}
-catch(IntlException $ie) {
- echo "IE: ".$ie->getMessage().PHP_EOL;
-}
+err($fmt);
$fmt = msgfmt_create('en');
err($fmt);
$fmt = MessageFormatter::create('en');
err($fmt);
foreach($args as $arg) {
- crt("O", $arg[0], $arg[1]);
- crt("C", $arg[0], $arg[1]);
- crt("P", $arg[0], $arg[1]);
+ $fmt = crt("O", $arg[0], $arg[1]);
+ err($fmt);
+ $fmt = crt("C", $arg[0], $arg[1]);
+ err($fmt);
+ $fmt = crt("P", $arg[0], $arg[1]);
+ err($fmt);
}
?>
--EXPECTF--
-IE: msgfmt_create: unable to parse input parameters
+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
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
@@ -80,21 +87,26 @@ 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'
-IE: msgfmt_create: unable to parse input parameters
+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
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
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
@@ -102,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/msgfmt_parse.phpt b/ext/intl/tests/msgfmt_parse.phpt
index 2eaf630010..b9ec36374b 100644
--- a/ext/intl/tests/msgfmt_parse.phpt
+++ b/ext/intl/tests/msgfmt_parse.phpt
@@ -36,15 +36,9 @@ function ut_main()
foreach( $locales as $locale => $pattern )
{
$str_res .= "\nLocale is: $locale\n";
- try {
- $fmt = ut_msgfmt_create( $locale, $pattern );
- if(!$fmt) {
- $str_res .= dump(intl_get_error_message())."\n";
- continue;
- }
- }
- catch (\IntlException $ie) {
- $str_res .= "IE: ".$ie->getMessage().PHP_EOL;
+ $fmt = ut_msgfmt_create( $locale, $pattern );
+ if(!$fmt) {
+ $str_res .= dump(intl_get_error_message())."\n";
continue;
}
$str_res .= dump( ut_msgfmt_parse( $fmt, $results[$locale] ) ) . "\n";
@@ -109,7 +103,7 @@ array (
)
Locale is: root
-IE: msgfmt_create: message formatter creation failed
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
Locale is: fr
array (
diff --git a/ext/intl/tests/resourcebundle_create.phpt b/ext/intl/tests/resourcebundle_create.phpt
index 99492a698b..2bf4f556a8 100644
--- a/ext/intl/tests/resourcebundle_create.phpt
+++ b/ext/intl/tests/resourcebundle_create.phpt
@@ -14,7 +14,6 @@ function ut_main() {
$str_res .= debug( $r1 );
$str_res .= print_r( $r1['teststring'], true)."\n";
-
// non-root one
$r1 = ut_resourcebundle_create( 'es', BUNDLE );
$str_res .= debug( $r1 );
@@ -25,22 +24,14 @@ function ut_main() {
$str_res .= debug( $r1 );
$str_res .= print_r( $r1['testsring'], true);
- try {
- // fall out
- $r2 = ut_resourcebundle_create( 'en_US', BUNDLE, false );
- }
- catch (\IntlException $ie) {
- $str_res .= "ie: ".$ie->getMessage().PHP_EOL;
- }
-
- try {
- // missing
- $r3 = ut_resourcebundle_create( 'en_US', 'nonexisting' );
- }
- catch (\IntlException $ie) {
- $str_res .= "ie: ".$ie->getMessage().PHP_EOL;
- }
+ // 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;
}
@@ -65,5 +56,7 @@ ResourceBundle Object
)
-127: U_USING_DEFAULT_WARNING
-ie: resourcebundle_ctor: Cannot load libICU resource bundle
-ie: resourcebundle_ctor: Cannot load libICU resource bundle
+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/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 )
{