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