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--EXPECTF--
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(%d) {%A
88    [%d]=>
89    int(3)
90  }
91  ["mon_grouping"]=>
92  array(%d) {%A
93    [%d]=>
94    int(3)
95  }
96}
97Setting system locale, category = LC_ALL and locale = 0
98Locale info, after setting the locale
99array(18) {
100  ["decimal_point"]=>
101  string(1) "."
102  ["thousands_sep"]=>
103  string(1) ","
104  ["int_curr_symbol"]=>
105  string(4) "USD "
106  ["currency_symbol"]=>
107  string(1) "$"
108  ["mon_decimal_point"]=>
109  string(1) "."
110  ["mon_thousands_sep"]=>
111  string(1) ","
112  ["positive_sign"]=>
113  string(0) ""
114  ["negative_sign"]=>
115  string(1) "-"
116  ["int_frac_digits"]=>
117  int(2)
118  ["frac_digits"]=>
119  int(2)
120  ["p_cs_precedes"]=>
121  int(1)
122  ["p_sep_by_space"]=>
123  int(0)
124  ["n_cs_precedes"]=>
125  int(1)
126  ["n_sep_by_space"]=>
127  int(0)
128  ["p_sign_posn"]=>
129  int(1)
130  ["n_sign_posn"]=>
131  int(1)
132  ["grouping"]=>
133  array(%d) {%A
134    [%d]=>
135    int(3)
136  }
137  ["mon_grouping"]=>
138  array(%d) {%A
139    [%d]=>
140    int(3)
141  }
142}
143Checking locale in the system, Expected : no change in the existing locale
144Test PASSED.
145Done
146