Annotation of embedaddon/php/ext/date/tests/timezone_name_from_abbr_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test timezone_name_from_abbr() function : usage variation - Passing unexpected values to first argument $abbr.
3: --FILE--
4: <?php
5: /* Prototype : string timezone_name_from_abbr ( string $abbr [, int $gmtOffset= -1 [, int $isdst= -1 ]] )
6: * Description: Returns the timezone name from abbrevation
7: * Source code: ext/date/php_date.c
8: * Alias to functions:
9: */
10:
11: echo "*** Testing timezone_name_from_abbr() : usage variation - unexpected values to first argument \$abbr***\n";
12:
13: //Set the default time zone
14: date_default_timezone_set("Europe/London");
15:
16: //get an unset variable
17: $unset_var = 10;
18: unset ($unset_var);
19:
20: // define some classes
21: class classWithToString
22: {
23: public function __toString() {
24: return "Class A object";
25: }
26: }
27:
28: class classWithoutToString
29: {
30: }
31:
32: // heredoc string
33: $heredoc = <<<EOT
34: hello world
35: EOT;
36:
37: // add arrays
38: $index_array = array (1, 2, 3);
39: $assoc_array = array ('one' => 1, 'two' => 2);
40:
41: // resource
42: $file_handle = fopen(__FILE__, 'r');
43:
44: //array of values to iterate over
45: $inputs = array(
46:
47: // int data
48: 'int 0' => 0,
49: 'int 12345' => 12345,
50: 'int -12345' => -12345,
51:
52: // float data
53: 'float 10.5' => 10.5,
54: 'float -10.5' => -10.5,
55: 'float .5' => .5,
56:
57: // array data
58: 'empty array' => array(),
59: 'int indexed array' => $index_array,
60: 'associative array' => $assoc_array,
61: 'nested arrays' => array('foo', $index_array, $assoc_array),
62:
63: // null data
64: 'uppercase NULL' => NULL,
65: 'lowercase null' => null,
66:
67: // boolean data
68: 'lowercase true' => true,
69: 'lowercase false' =>false,
70: 'uppercase TRUE' =>TRUE,
71: 'uppercase FALSE' =>FALSE,
72:
73: // empty data
74: 'empty string DQ' => "",
75: 'empty string SQ' => '',
76:
77: // string data
78: 'string DQ' => "string",
79: 'string SQ' => 'string',
80: 'mixed case string' => "sTrInG",
81: 'heredoc' => $heredoc,
82:
83: // object data
84: 'instance of classWithToString' => new classWithToString(),
85: 'instance of classWithoutToString' => new classWithoutToString(),
86:
87: // undefined data
88: 'undefined var' => @$undefined_var,
89:
90: // unset data
91: 'unset var' => @$unset_var,
92:
93: // resource
94: 'resource' => $file_handle
95: );
96:
97: $gmtOffset= 3600;
98: $isdst = 1;
99:
100: foreach($inputs as $variation =>$abbr) {
101: echo "\n-- $variation --\n";
102: var_dump( timezone_name_from_abbr($abbr, $gmtOffset, $isdst) );
103: };
104:
105: // closing the resource
106: fclose( $file_handle );
107:
108: ?>
109: ===DONE===
110: --EXPECTF--
111: *** Testing timezone_name_from_abbr() : usage variation - unexpected values to first argument $abbr***
112:
113: -- int 0 --
114: string(13) "Europe/London"
115:
116: -- int 12345 --
117: string(13) "Europe/London"
118:
119: -- int -12345 --
120: string(13) "Europe/London"
121:
122: -- float 10.5 --
123: string(13) "Europe/London"
124:
125: -- float -10.5 --
126: string(13) "Europe/London"
127:
128: -- float .5 --
129: string(13) "Europe/London"
130:
131: -- empty array --
132:
133: Warning: timezone_name_from_abbr() expects parameter 1 to be string, array given in %s on line %d
134: bool(false)
135:
136: -- int indexed array --
137:
138: Warning: timezone_name_from_abbr() expects parameter 1 to be string, array given in %s on line %d
139: bool(false)
140:
141: -- associative array --
142:
143: Warning: timezone_name_from_abbr() expects parameter 1 to be string, array given in %s on line %d
144: bool(false)
145:
146: -- nested arrays --
147:
148: Warning: timezone_name_from_abbr() expects parameter 1 to be string, array given in %s on line %d
149: bool(false)
150:
151: -- uppercase NULL --
152: string(13) "Europe/London"
153:
154: -- lowercase null --
155: string(13) "Europe/London"
156:
157: -- lowercase true --
158: string(13) "Europe/London"
159:
160: -- lowercase false --
161: string(13) "Europe/London"
162:
163: -- uppercase TRUE --
164: string(13) "Europe/London"
165:
166: -- uppercase FALSE --
167: string(13) "Europe/London"
168:
169: -- empty string DQ --
170: string(13) "Europe/London"
171:
172: -- empty string SQ --
173: string(13) "Europe/London"
174:
175: -- string DQ --
176: string(13) "Europe/London"
177:
178: -- string SQ --
179: string(13) "Europe/London"
180:
181: -- mixed case string --
182: string(13) "Europe/London"
183:
184: -- heredoc --
185: string(13) "Europe/London"
186:
187: -- instance of classWithToString --
188: string(13) "Europe/London"
189:
190: -- instance of classWithoutToString --
191:
192: Warning: timezone_name_from_abbr() expects parameter 1 to be string, object given in %s on line %d
193: bool(false)
194:
195: -- undefined var --
196: string(13) "Europe/London"
197:
198: -- unset var --
199: string(13) "Europe/London"
200:
201: -- resource --
202:
203: Warning: timezone_name_from_abbr() expects parameter 1 to be string, resource given in %s on line %d
204: bool(false)
205: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>