xref: /PHP-7.0/ext/intl/tests/msgfmt_bug70484.phpt (revision 22336db9)
1--TEST--
2Bug #70484 selectordinal doesn't work with named parameters
3--SKIPIF--
4<?php
5if (!extension_loaded('intl'))
6	die('skip intl extension not enabled');
7if (version_compare(INTL_ICU_VERSION, '5.0') < 0)
8	die('skip for ICU 5.0+');
9--FILE--
10<?php
11
12$locale = array("de", "fr", "en", "ru",);
13
14$data = array(42, 42.42, 2147483643, 2147483643.12345, 5);
15
16foreach ($locale as $lc) {
17	echo "$lc string key\n";
18	$m = new MessageFormatter($lc, "{n, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}");
19	foreach ($data as $i) {
20		var_dump($m->format(array("n" => $i)));
21		if ($m->getErrorCode()) {
22			echo "$lc $i ", $m->getErrorMessage();
23		}
24	}
25	echo "\n";
26
27	echo "$lc numeric key\n";
28	$m = new MessageFormatter($lc, "{0, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}");
29	foreach ($data as $i) {
30		var_dump($m->format(array($i)));
31		if ($m->getErrorCode()) {
32			echo "$lc $i ", $m->getErrorMessage();
33		}
34	}
35	echo "\n";
36}
37
38?>
39==DONE==
40--EXPECT--
41de string key
42string(8) "42-other"
43string(11) "42,42-other"
44string(19) "2.147.483.643-other"
45string(23) "2.147.483.643,123-other"
46string(4) "five"
47
48de numeric key
49string(8) "42-other"
50string(11) "42,42-other"
51string(19) "2.147.483.643-other"
52string(23) "2.147.483.643,123-other"
53string(4) "five"
54
55fr string key
56string(8) "42-other"
57string(11) "42,42-other"
58string(22) "2 147 483 643-other"
59string(26) "2 147 483 643,123-other"
60string(4) "five"
61
62fr numeric key
63string(8) "42-other"
64string(11) "42,42-other"
65string(22) "2 147 483 643-other"
66string(26) "2 147 483 643,123-other"
67string(4) "five"
68
69en string key
70string(6) "42-two"
71string(11) "42.42-other"
72string(17) "2,147,483,643-few"
73string(23) "2,147,483,643.123-other"
74string(4) "five"
75
76en numeric key
77string(6) "42-two"
78string(11) "42.42-other"
79string(17) "2,147,483,643-few"
80string(23) "2,147,483,643.123-other"
81string(4) "five"
82
83ru string key
84string(8) "42-other"
85string(11) "42,42-other"
86string(22) "2 147 483 643-other"
87string(26) "2 147 483 643,123-other"
88string(4) "five"
89
90ru numeric key
91string(8) "42-other"
92string(11) "42,42-other"
93string(22) "2 147 483 643-other"
94string(26) "2 147 483 643,123-other"
95string(4) "five"
96
97==DONE==
98