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