xref: /PHP-8.0/ext/intl/tests/msgfmt_bug70484.phpt (revision c5401854)
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--EXPECTF--
38de string key
39string(8) "42-other"
40string(11) "42,42-other"
41string(19) "2.147.483.643-other"
42string(23) "2.147.483.643,123-other"
43string(4) "five"
44
45de numeric key
46string(8) "42-other"
47string(11) "42,42-other"
48string(19) "2.147.483.643-other"
49string(23) "2.147.483.643,123-other"
50string(4) "five"
51
52fr string key
53string(8) "42-other"
54string(11) "42,42-other"
55string(%d) "2%s147%s483%s643-other"
56string(%d) "2%s147%s483%s643,123-other"
57string(4) "five"
58
59fr numeric key
60string(8) "42-other"
61string(11) "42,42-other"
62string(%d) "2%s147%s483%s643-other"
63string(%d) "2%s147%s483%s643,123-other"
64string(4) "five"
65
66en string key
67string(6) "42-two"
68string(11) "42.42-other"
69string(17) "2,147,483,643-few"
70string(23) "2,147,483,643.123-other"
71string(4) "five"
72
73en numeric key
74string(6) "42-two"
75string(11) "42.42-other"
76string(17) "2,147,483,643-few"
77string(23) "2,147,483,643.123-other"
78string(4) "five"
79
80ru string key
81string(8) "42-other"
82string(11) "42,42-other"
83string(22) "2 147 483 643-other"
84string(26) "2 147 483 643,123-other"
85string(4) "five"
86
87ru numeric key
88string(8) "42-other"
89string(11) "42,42-other"
90string(22) "2 147 483 643-other"
91string(26) "2 147 483 643,123-other"
92string(4) "five"
93
94