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