1--TEST--
2ValueErrors for format/parse methods and procedural functions
3--EXTENSIONS--
4intl
5--FILE--
6<?php
7
8$o = new NumberFormatter('en_US', NumberFormatter::PATTERN_DECIMAL);
9$num = 5;
10$str = "string";
11
12/* Unknown type constant */
13try {
14    numfmt_format($o, $num, -20);
15} catch (\ValueError $e) {
16    echo $e->getMessage(), \PHP_EOL;
17}
18try {
19    $o->format($num, -20);
20} catch (\ValueError $e) {
21    echo $e->getMessage(), \PHP_EOL;
22}
23try {
24    numfmt_parse($o, $str, -20);
25} catch (\ValueError $e) {
26    echo $e->getMessage(), \PHP_EOL;
27}
28try {
29    $o->parse($str, -20);
30} catch (\ValueError $e) {
31    echo $e->getMessage(), \PHP_EOL;
32}
33
34/* With NumberFormatter::TYPE_CURRENCY */
35try {
36    numfmt_format($o, $num, NumberFormatter::TYPE_CURRENCY);
37} catch (\ValueError $e) {
38    echo $e->getMessage(), \PHP_EOL;
39}
40try {
41    $o->format($num, NumberFormatter::TYPE_CURRENCY);
42} catch (\ValueError $e) {
43    echo $e->getMessage(), \PHP_EOL;
44}
45try {
46    numfmt_parse($o, $str, NumberFormatter::TYPE_CURRENCY);
47} catch (\ValueError $e) {
48    echo $e->getMessage(), \PHP_EOL;
49}
50try {
51    $o->parse($str, NumberFormatter::TYPE_CURRENCY);
52} catch (\ValueError $e) {
53    echo $e->getMessage(), \PHP_EOL;
54}
55
56?>
57--EXPECT--
58numfmt_format(): Argument #3 ($type) must be a NumberFormatter::TYPE_* constant
59NumberFormatter::format(): Argument #2 ($type) must be a NumberFormatter::TYPE_* constant
60numfmt_parse(): Argument #3 ($type) must be a NumberFormatter::TYPE_* constant
61NumberFormatter::parse(): Argument #2 ($type) must be a NumberFormatter::TYPE_* constant
62numfmt_format(): Argument #3 ($type) cannot be NumberFormatter::TYPE_CURRENCY constant, use numfmt_format_currency() function instead
63NumberFormatter::format(): Argument #2 ($type) cannot be NumberFormatter::TYPE_CURRENCY constant, use NumberFormatter::formatCurrency() method instead
64numfmt_parse(): Argument #3 ($type) cannot be NumberFormatter::TYPE_CURRENCY constant, use numfmt_parse_currency() function instead
65NumberFormatter::parse(): Argument #2 ($type) cannot be NumberFormatter::TYPE_CURRENCY constant, use NumberFormatter::parseCurrency() method instead
66