1--TEST--
2Test setlocale() function : usage variations - Setting system locale as empty string
3--SKIPIF--
4<?php
5if (setlocale(LC_ALL, 'invalid') === 'invalid') { die('skip setlocale() is broken /w musl'); }
6if (substr(PHP_OS, 0, 3) == 'WIN') {
7    die('skip Not valid for windows');
8}
9if (setlocale(LC_ALL,'en_AU.utf8') === false || setlocale(LC_ALL,'en_US.utf8') === false) {
10    die('skip en_AU.utf8/en_US.utf8 locales not available');
11}
12?>
13--ENV--
14LC_ALL=en_US.utf8;
15--FILE--
16<?php
17/* If locale is empty string "", the locale names will be set from the values of environment variables with the same names as from ENV */
18
19echo "*** Testing setlocale() : usage variations - setting system locale = \"\" ***\n";
20
21//initially setting the locale
22setlocale(LC_ALL,'en_AU.utf8');
23
24echo "Locale info, before setting the locale\n";
25
26//returns current locale,before executing setlocale() .
27$locale_info_before = localeconv();
28
29var_dump($locale_info_before);
30
31//Testing setlocale()  by giving locale = null
32echo "Setting system locale, category = LC_ALL and locale = \"\"\n";
33setlocale(LC_ALL, "");
34
35echo "Locale info, after setting the locale\n";
36
37//Returns Current locale,after executing setlocale().
38$locale_info_after = localeconv();
39
40var_dump($locale_info_after);
41
42echo "Checking new locale in the system, Expected : the locale names will be set from the values of environment variables\n";
43echo "Test ";
44if($locale_info_before != $locale_info_after){
45  echo "PASSED.";
46} else {
47  echo "FAILED.";
48}
49
50echo "\nDone\n";
51?>
52--EXPECTF--
53*** Testing setlocale() : usage variations - setting system locale = "" ***
54Locale info, before setting the locale
55array(18) {
56  ["decimal_point"]=>
57  string(1) "."
58  ["thousands_sep"]=>
59  string(1) ","
60  ["int_curr_symbol"]=>
61  string(4) "AUD "
62  ["currency_symbol"]=>
63  string(1) "$"
64  ["mon_decimal_point"]=>
65  string(1) "."
66  ["mon_thousands_sep"]=>
67  string(1) ","
68  ["positive_sign"]=>
69  string(0) ""
70  ["negative_sign"]=>
71  string(1) "-"
72  ["int_frac_digits"]=>
73  int(2)
74  ["frac_digits"]=>
75  int(2)
76  ["p_cs_precedes"]=>
77  int(1)
78  ["p_sep_by_space"]=>
79  int(0)
80  ["n_cs_precedes"]=>
81  int(1)
82  ["n_sep_by_space"]=>
83  int(0)
84  ["p_sign_posn"]=>
85  int(1)
86  ["n_sign_posn"]=>
87  int(1)
88  ["grouping"]=>
89  array(%d) {%A
90    [%d]=>
91    int(3)
92  }
93  ["mon_grouping"]=>
94  array(%d) {%A
95    [%d]=>
96    int(3)
97  }
98}
99Setting system locale, category = LC_ALL and locale = ""
100Locale info, after setting the locale
101array(18) {
102  ["decimal_point"]=>
103  string(1) "."
104  ["thousands_sep"]=>
105  string(1) ","
106  ["int_curr_symbol"]=>
107  string(4) "USD "
108  ["currency_symbol"]=>
109  string(1) "$"
110  ["mon_decimal_point"]=>
111  string(1) "."
112  ["mon_thousands_sep"]=>
113  string(1) ","
114  ["positive_sign"]=>
115  string(0) ""
116  ["negative_sign"]=>
117  string(1) "-"
118  ["int_frac_digits"]=>
119  int(2)
120  ["frac_digits"]=>
121  int(2)
122  ["p_cs_precedes"]=>
123  int(1)
124  ["p_sep_by_space"]=>
125  int(0)
126  ["n_cs_precedes"]=>
127  int(1)
128  ["n_sep_by_space"]=>
129  int(0)
130  ["p_sign_posn"]=>
131  int(1)
132  ["n_sign_posn"]=>
133  int(1)
134  ["grouping"]=>
135  array(%d) {%A
136    [%d]=>
137    int(3)
138  }
139  ["mon_grouping"]=>
140  array(%d) {%A
141    [%d]=>
142    int(3)
143  }
144}
145Checking new locale in the system, Expected : the locale names will be set from the values of environment variables
146Test PASSED.
147Done
148