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--EXPECT--
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(2) {
86    [0]=>
87    int(3)
88    [1]=>
89    int(3)
90  }
91  ["mon_grouping"]=>
92  array(2) {
93    [0]=>
94    int(3)
95    [1]=>
96    int(3)
97  }
98}
99Setting system locale, category = LC_ALL and locale = null
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(2) {
136    [0]=>
137    int(3)
138    [1]=>
139    int(3)
140  }
141  ["mon_grouping"]=>
142  array(2) {
143    [0]=>
144    int(3)
145    [1]=>
146    int(3)
147  }
148}
149Checking new locale in the system, Expected : the locale names will be set from the values of environment variables
150Test PASSED.
151Done
152