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