diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-03-30 12:14:43 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-03-30 12:14:43 +0300 |
commit | 9155a267adeeb6f442f97892de441e4b6666ce73 (patch) | |
tree | 7d525ab7379401c38b4416886655b4753ec5701a /ext/intl/tests | |
parent | c71c97e101f239d487c7a9797bdf193098d469ca (diff) | |
parent | 910a3243063f0490a60e5c3c0e1467a6171f4e39 (diff) | |
download | php-git-9155a267adeeb6f442f97892de441e4b6666ce73.tar.gz |
Merge branch 'InternalClassClean' of github.com:Danack/php-src into InternalClassClean
* 'InternalClassClean' of github.com:Danack/php-src:
Fixed indentation. Fixed comment style. Fixed commented out code.
Reverted change to function name and added note of why it is different from the class it is actually changing.
Made UConverter throw an exception if the constructor fails.
Fixed PDO constructor to not return null.
Fixed fileinfo behaviour.
Made Phar throw exception on bad constructor.
Converted intl extension to use IntlException in constructors.
Fixed SplFixedArray and tests.
Fixed ReflectionExtension and ReflectionProperty.
Fixed ReflectionFunction, ReflectionMethod and ReflectionParameter.
Fixed PDORow behaviour and message.
Diffstat (limited to 'ext/intl/tests')
-rw-r--r-- | ext/intl/tests/bug62017.phpt | 12 | ||||
-rw-r--r-- | ext/intl/tests/formatter_fail.phpt | 53 | ||||
-rw-r--r-- | ext/intl/tests/formatter_format.phpt | 9 | ||||
-rw-r--r-- | ext/intl/tests/gregoriancalendar___construct_error.phpt | 22 | ||||
-rw-r--r-- | ext/intl/tests/msgfmt_fail.phpt | 61 | ||||
-rw-r--r-- | ext/intl/tests/msgfmt_parse.phpt | 14 | ||||
-rw-r--r-- | ext/intl/tests/resourcebundle_create.phpt | 29 |
7 files changed, 124 insertions, 76 deletions
diff --git a/ext/intl/tests/bug62017.phpt b/ext/intl/tests/bug62017.phpt index 50aeae4806..e5c216c1e2 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( +try { new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon", - IntlDateFormatter::GREGORIAN, "\x80")); + IntlDateFormatter::GREGORIAN, "\x80"); +} +catch(IntlException $ie) { + echo $ie->getMessage().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 +datefmt_create: error converting pattern to UTF-16 diff --git a/ext/intl/tests/formatter_fail.phpt b/ext/intl/tests/formatter_fail.phpt index 295f011008..c45b113bdb 100644 --- a/ext/intl/tests/formatter_fail.phpt +++ b/ext/intl/tests/formatter_fail.phpt @@ -12,16 +12,23 @@ function err($fmt) { } function crt($t, $l, $s) { - switch(true) { - case $t == "O": - return new NumberFormatter($l, $s); - break; - case $t == "C": - return NumberFormatter::create($l, $s); - break; - case $t == "P": - return numfmt_create($l, $s); - break; + 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; } } @@ -33,8 +40,13 @@ $args = array( array("en_US", NumberFormatter::PATTERN_RULEBASED), ); -$fmt = new NumberFormatter(); -err($fmt); +try { + $fmt = new NumberFormatter(); +} +catch(IntlException $ie) { + echo $ie->getMessage().PHP_EOL; +} + $fmt = numfmt_create(); err($fmt); $fmt = NumberFormatter::create(); @@ -42,11 +54,8 @@ 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); } ?> @@ -70,10 +79,10 @@ Warning: NumberFormatter::create() expects parameter 1 to be string, array given '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 -'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' -'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' -'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' +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 diff --git a/ext/intl/tests/formatter_format.phpt b/ext/intl/tests/formatter_format.phpt index 334ef49567..0fa88681d9 100644 --- a/ext/intl/tests/formatter_format.phpt +++ b/ext/intl/tests/formatter_format.phpt @@ -50,7 +50,14 @@ function ut_main() $str_res .= "\nLocale is: $locale\n"; foreach( $styles as $style => $pattern ) { - $fmt = ut_nfmt_create( $locale, $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; + } 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 45229cf000..a28fa715e4 100644 --- a/ext/intl/tests/gregoriancalendar___construct_error.phpt +++ b/ext/intl/tests/gregoriancalendar___construct_error.phpt @@ -11,8 +11,18 @@ ini_set("intl.error_level", E_WARNING); 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 { + new IntlGregorianCalendar(1,2,NULL,4); +} +catch (IntlException $ie) { + echo "IE: ".$ie->getMessage().PHP_EOL; +} +try { + new IntlGregorianCalendar(1,2,3,4,NULL,array()); +} +catch (IntlException $ie) { + echo "IE: ".$ie->getMessage().PHP_EOL; +} --EXPECTF-- @@ -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 - +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 - -Warning: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: bad arguments in %s on line %d -NULL +IE: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: bad arguments diff --git a/ext/intl/tests/msgfmt_fail.phpt b/ext/intl/tests/msgfmt_fail.phpt index bffb71c56d..4b60b35abc 100644 --- a/ext/intl/tests/msgfmt_fail.phpt +++ b/ext/intl/tests/msgfmt_fail.phpt @@ -13,16 +13,24 @@ function err($fmt) { } function crt($t, $l, $s) { - switch(true) { - case $t == "O": - return new MessageFormatter($l, $s); - break; - case $t == "C": - return MessageFormatter::create($l, $s); - break; - case $t == "P": - return msgfmt_create($l, $s); - break; + + 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; } } @@ -35,32 +43,36 @@ $args = array( array("en_US", "\xD0"), ); -$fmt = new MessageFormatter(); -err($fmt); +try { + $fmt = new MessageFormatter(); +} +catch(IntlException $ie) { + echo "IE: ".$ie->getMessage().PHP_EOL; +} $fmt = msgfmt_create(); err($fmt); $fmt = MessageFormatter::create(); -err($fmt); -$fmt = new MessageFormatter('en'); -err($fmt); +err($fmt); +try { + $fmt = new MessageFormatter('en'); +} +catch(IntlException $ie) { + echo "IE: ".$ie->getMessage().PHP_EOL; +} $fmt = msgfmt_create('en'); err($fmt); $fmt = MessageFormatter::create('en'); 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); + crt("O", $arg[0], $arg[1]); + crt("C", $arg[0], $arg[1]); + crt("P", $arg[0], $arg[1]); } ?> --EXPECTF-- -Warning: MessageFormatter::__construct() 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 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' @@ -68,8 +80,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 -'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' +IE: msgfmt_create: unable to parse input parameters 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' diff --git a/ext/intl/tests/msgfmt_parse.phpt b/ext/intl/tests/msgfmt_parse.phpt index b9ec36374b..2eaf630010 100644 --- a/ext/intl/tests/msgfmt_parse.phpt +++ b/ext/intl/tests/msgfmt_parse.phpt @@ -36,9 +36,15 @@ function ut_main() foreach( $locales as $locale => $pattern ) { $str_res .= "\nLocale is: $locale\n"; - $fmt = ut_msgfmt_create( $locale, $pattern ); - if(!$fmt) { - $str_res .= dump(intl_get_error_message())."\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; continue; } $str_res .= dump( ut_msgfmt_parse( $fmt, $results[$locale] ) ) . "\n"; @@ -103,7 +109,7 @@ array ( ) Locale is: root -'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' +IE: msgfmt_create: message formatter creation failed Locale is: fr array ( diff --git a/ext/intl/tests/resourcebundle_create.phpt b/ext/intl/tests/resourcebundle_create.phpt index 2bf4f556a8..99492a698b 100644 --- a/ext/intl/tests/resourcebundle_create.phpt +++ b/ext/intl/tests/resourcebundle_create.phpt @@ -14,6 +14,7 @@ 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 ); @@ -24,14 +25,22 @@ 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 ); + 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; + } - // missing - $r3 = ut_resourcebundle_create( 'en_US', 'nonexisting' ); - $str_res .= debug( $r3 ); - return $str_res; } @@ -56,7 +65,5 @@ 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 +ie: resourcebundle_ctor: Cannot load libICU resource bundle +ie: resourcebundle_ctor: Cannot load libICU resource bundle |