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