xref: /PHP-7.4/ext/intl/tests/msgfmt_bug70484.phpt (revision 4461fb9c)
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');
7--FILE--
8<?php
9
10$locale = array("de", "fr", "en", "ru",);
11
12$data = array(42, 42.42, 2147483643, 2147483643.12345, 5);
13
14foreach ($locale as $lc) {
15	echo "$lc string key\n";
16	$m = new MessageFormatter($lc, "{n, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}");
17	foreach ($data as $i) {
18		var_dump($m->format(array("n" => $i)));
19		if ($m->getErrorCode()) {
20			echo "$lc $i ", $m->getErrorMessage();
21		}
22	}
23	echo "\n";
24
25	echo "$lc numeric key\n";
26	$m = new MessageFormatter($lc, "{0, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}");
27	foreach ($data as $i) {
28		var_dump($m->format(array($i)));
29		if ($m->getErrorCode()) {
30			echo "$lc $i ", $m->getErrorMessage();
31		}
32	}
33	echo "\n";
34}
35
36?>
37==DONE==
38--EXPECTF--
39de string key
40string(8) "42-other"
41string(11) "42,42-other"
42string(19) "2.147.483.643-other"
43string(23) "2.147.483.643,123-other"
44string(4) "five"
45
46de numeric key
47string(8) "42-other"
48string(11) "42,42-other"
49string(19) "2.147.483.643-other"
50string(23) "2.147.483.643,123-other"
51string(4) "five"
52
53fr string key
54string(8) "42-other"
55string(11) "42,42-other"
56string(%d) "2%s147%s483%s643-other"
57string(%d) "2%s147%s483%s643,123-other"
58string(4) "five"
59
60fr numeric key
61string(8) "42-other"
62string(11) "42,42-other"
63string(%d) "2%s147%s483%s643-other"
64string(%d) "2%s147%s483%s643,123-other"
65string(4) "five"
66
67en string key
68string(6) "42-two"
69string(11) "42.42-other"
70string(17) "2,147,483,643-few"
71string(23) "2,147,483,643.123-other"
72string(4) "five"
73
74en numeric key
75string(6) "42-two"
76string(11) "42.42-other"
77string(17) "2,147,483,643-few"
78string(23) "2,147,483,643.123-other"
79string(4) "five"
80
81ru string key
82string(8) "42-other"
83string(11) "42,42-other"
84string(22) "2 147 483 643-other"
85string(26) "2 147 483 643,123-other"
86string(4) "five"
87
88ru numeric key
89string(8) "42-other"
90string(11) "42,42-other"
91string(22) "2 147 483 643-other"
92string(26) "2 147 483 643,123-other"
93string(4) "five"
94
95==DONE==
96