xref: /PHP-5.5/ext/intl/tests/formatter_fail.phpt (revision 9762609c)
1--TEST--
2numfmt creation failures
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5--FILE--
6<?php
7
8function err($fmt) {
9	if(!$fmt) {
10		echo var_export(intl_get_error_message(), true)."\n";
11	}
12}
13
14function crt($t, $l, $s) {
15	switch(true) {
16		case $t == "O":
17			return new NumberFormatter($l, $s);
18			break;
19		case $t == "C":
20			return NumberFormatter::create($l, $s);
21			break;
22		case $t == "P":
23			return numfmt_create($l, $s);
24			break;
25	}
26}
27
28$args = array(
29	array(null, null),
30	array("whatever", 1234567),
31	array(array(), array()),
32	array("en", -1),
33	array("en_US", NumberFormatter::PATTERN_RULEBASED),
34);
35
36$fmt = new NumberFormatter();
37err($fmt);
38$fmt = numfmt_create();
39err($fmt);
40$fmt = NumberFormatter::create();
41err($fmt);
42
43foreach($args as $arg) {
44	$fmt = crt("O", $arg[0], $arg[1]);
45	err($fmt);
46	$fmt = crt("C", $arg[0], $arg[1]);
47	err($fmt);
48	$fmt = crt("P", $arg[0], $arg[1]);
49	err($fmt);
50}
51
52?>
53--EXPECTF--
54Warning: NumberFormatter::__construct() expects at least 2 parameters, 0 given in %s on line %d
55'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
56
57Warning: numfmt_create() expects at least 2 parameters, 0 given in %s on line %d
58'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
59
60Warning: NumberFormatter::create() expects at least 2 parameters, 0 given in %s on line %d
61'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
62'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
63'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
64'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
65
66Warning: NumberFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
67'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
68
69Warning: NumberFormatter::create() expects parameter 1 to be string, array given in %s on line %d
70'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
71
72Warning: numfmt_create() expects parameter 1 to be string, array given in %s on line %d
73'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
74'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
75'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
76'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
77'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
78'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
79'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
80