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