xref: /PHP-5.3/ext/intl/tests/msgfmt_fail2.phpt (revision bd928f05)
1--TEST--
2msgfmt creation failures icu >= 4.8
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
6--FILE--
7<?php
8
9function err($fmt) {
10	if(!$fmt) {
11		echo var_export(intl_get_error_message(), true)."\n";
12	}
13}
14
15function crt($t, $l, $s) {
16	switch(true) {
17		case $t == "O":
18			return new MessageFormatter($l, $s);
19			break;
20		case $t == "C":
21			return MessageFormatter::create($l, $s);
22			break;
23		case $t == "P":
24			return msgfmt_create($l, $s);
25			break;
26	}
27}
28
29$args = array(
30	array(null, null),
31	array("whatever", "{0,whatever}"),
32	array(array(), array()),
33	array("en", "{0,choice}"),
34	array("fr", "{0,"),
35	array("en_US", "\xD0"),
36);
37
38$fmt = new MessageFormatter();
39err($fmt);
40$fmt = msgfmt_create();
41err($fmt);
42$fmt = MessageFormatter::create();
43err($fmt);
44$fmt = new MessageFormatter('en');
45err($fmt);
46$fmt = msgfmt_create('en');
47err($fmt);
48$fmt = MessageFormatter::create('en');
49err($fmt);
50
51foreach($args as $arg) {
52	$fmt = crt("O", $arg[0], $arg[1]);
53	err($fmt);
54	$fmt = crt("C", $arg[0], $arg[1]);
55	err($fmt);
56	$fmt = crt("P", $arg[0], $arg[1]);
57	err($fmt);
58}
59
60?>
61--EXPECTF--
62Warning: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d
63'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
64
65Warning: msgfmt_create() expects exactly 2 parameters, 0 given in %s on line %d
66'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
67
68Warning: MessageFormatter::create() expects exactly 2 parameters, 0 given in %s on line %d
69'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
70
71Warning: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d
72'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
73
74Warning: msgfmt_create() expects exactly 2 parameters, 1 given in %s on line %d
75'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
76
77Warning: MessageFormatter::create() expects exactly 2 parameters, 1 given in %s on line %d
78'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
79'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
80'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
81'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
82'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
83'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
84'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
85
86Warning: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
87'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
88
89Warning: MessageFormatter::create() expects parameter 1 to be string, array given in %s on line %d
90'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
91
92Warning: msgfmt_create() expects parameter 1 to be string, array given in %s on line %d
93'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
94'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR'
95'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR'
96'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR'
97'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
98'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
99'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
100'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
101'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
102'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
103