From: Gustavo André dos Santos Lopes Date: Sun, 6 May 2012 23:18:30 +0000 (+0200) Subject: Added new MessageFormatter tests. X-Git-Tag: php-5.5.0alpha1~206^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0295ed7d225dcd9f5cbd21cfb335912a87af894d;p=php Added new MessageFormatter tests. --- diff --git a/ext/intl/tests/msgfmt_format_datetime.phpt b/ext/intl/tests/msgfmt_format_datetime.phpt new file mode 100644 index 0000000000..a79b822b6d --- /dev/null +++ b/ext/intl/tests/msgfmt_format_datetime.phpt @@ -0,0 +1,26 @@ +--TEST-- +MessageFormatter::format(): DateTime accepted to format dates and times +--SKIPIF-- +format(array($dt))); + +?> +==DONE== +--EXPECTF-- +string(%s) "May %d, 2012 %d:%d:42 %s" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/msgfmt_format_error1.phpt b/ext/intl/tests/msgfmt_format_error1.phpt new file mode 100644 index 0000000000..09d022bdfd --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error1.phpt @@ -0,0 +1,21 @@ +--TEST-- +MessageFormatter::format() insufficient numeric arguments +--SKIPIF-- +format(array(7))); + +--EXPECTF-- + +Warning: MessageFormatter::format(): msgfmt_format: not enough parameters in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_error2.phpt b/ext/intl/tests/msgfmt_format_error2.phpt new file mode 100644 index 0000000000..00b8542ed1 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error2.phpt @@ -0,0 +1,21 @@ +--TEST-- +MessageFormatter::format() inconsistent types in named argument +--SKIPIF-- +format(array(7))); + +--EXPECTF-- + +Warning: MessageFormatter::format(): Inconsistent types declared for an argument in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_error3.phpt b/ext/intl/tests/msgfmt_format_error3.phpt new file mode 100644 index 0000000000..98eebd7e64 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error3.phpt @@ -0,0 +1,21 @@ +--TEST-- +MessageFormatter::format() given negative arg key +--SKIPIF-- +format(array("foo" => 7, -1 => "bar"))); + +--EXPECTF-- + +Warning: MessageFormatter::format(): Found negative or too large array key in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_error4.phpt b/ext/intl/tests/msgfmt_format_error4.phpt new file mode 100644 index 0000000000..5f4d006178 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error4.phpt @@ -0,0 +1,26 @@ +--TEST-- +MessageFormatter::format() invalid UTF-8 for arg key or value +--SKIPIF-- +format(array("foo" => 7, "\x80" => "bar"))); + +var_dump($mf->format(array("foo" => "\x80"))); + +--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) diff --git a/ext/intl/tests/msgfmt_format_error5.phpt b/ext/intl/tests/msgfmt_format_error5.phpt new file mode 100644 index 0000000000..951cd3ff2e --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error5.phpt @@ -0,0 +1,21 @@ +--TEST-- +MessageFormatter::format() invalid date/time argument +--SKIPIF-- +format(array("foo" => new stdclass()))); + +--EXPECTF-- + +Warning: MessageFormatter::format(): The argument for key 'foo' cannot be used as a date or time in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_error6.phpt b/ext/intl/tests/msgfmt_format_error6.phpt new file mode 100644 index 0000000000..aefed90e97 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error6.phpt @@ -0,0 +1,21 @@ +--TEST-- +MessageFormatter::format() invalid type for key not in pattern +--SKIPIF-- +format(array("foo" => 'bar', 7 => fopen('php://memory', 'r+')))); + +--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) diff --git a/ext/intl/tests/msgfmt_format_mixed_params.phpt b/ext/intl/tests/msgfmt_format_mixed_params.phpt new file mode 100644 index 0000000000..3ab7688b55 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_mixed_params.phpt @@ -0,0 +1,23 @@ +--TEST-- +MessageFormatter::format(): mixed named and numeric parameters +--SKIPIF-- +format(array(2.3, "foo" => 1.3))); +var_dump($mf->format(array("foo" => 1.3, 0 => 2.3))); + +?> +==DONE== +--EXPECT-- +string(10) "2.3 -- 1st" +string(10) "2.3 -- 1st" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt b/ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt new file mode 100644 index 0000000000..39cf815b01 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt @@ -0,0 +1,54 @@ +--TEST-- +MessageFormatter::format(): simple types handling with numeric strings +--SKIPIF-- +format(array( +'a' => $ex, +'b' => $ex, +'c' => $ex, +'d' => $ex, +'e' => $ex, +'f' => " 1336317965.5", +'g' => " 1336317965.5", +'h' => $ex, +'i' => $ex, +'j' => $ex, +))); + +?> +==DONE== +--EXPECTF-- +string(%d) " + none 1336317965.5 str + number 1,336,317,965.5 + number integer 1,336,317,965 + number currency $1,336,317,965.50 + number percent 133,631,796,550% + date May %d, 2012 + time %d:%d:05 PM + spellout one billion three hundred thirty-six million three hundred seventeen thousand nine hundred sixty-five point five + ordinal 1,336,317,966th + duration 371,199:26:06 + " +==DONE== \ No newline at end of file