Annotation of embedaddon/php/ext/date/tests/timezone_transitions_get_variation3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test timezone_transitions_get() function : usage variation - Passing unexpected values to first argument $timestamp_env.
3: --FILE--
4: <?php
5: /* Prototype : array timezone_transitions_get ( DateTimeZone $object, [ int $timestamp_begin [, int $timestamp_end ]] )
6: * Description: Returns all transitions for the timezone
7: * Source code: ext/date/php_date.c
8: * Alias to functions: DateTimeZone::getTransitions()
9: */
10:
11: echo "*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument \$timestamp_end ***\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 1' => 1,
50: 'int 12345' => 12345,
51: 'int -12345' => -12345,
52:
53: // float data
54: 'float 10.5' => 10.5,
55: 'float -10.5' => -10.5,
56: 'float .5' => .5,
57:
58: // array data
59: 'empty array' => array(),
60: 'int indexed array' => $index_array,
61: 'associative array' => $assoc_array,
62: 'nested arrays' => array('foo', $index_array, $assoc_array),
63:
64: // null data
65: 'uppercase NULL' => NULL,
66: 'lowercase null' => null,
67:
68: // boolean data
69: 'lowercase true' => true,
70: 'lowercase false' =>false,
71: 'uppercase TRUE' =>TRUE,
72: 'uppercase FALSE' =>FALSE,
73:
74: // empty data
75: 'empty string DQ' => "",
76: 'empty string SQ' => '',
77:
78: // string data
79: 'string DQ' => "string",
80: 'string SQ' => 'string',
81: 'mixed case string' => "sTrInG",
82: 'heredoc' => $heredoc,
83:
84: // object data
85: 'instance of classWithToString' => new classWithToString(),
86: 'instance of classWithoutToString' => new classWithoutToString(),
87:
88: // undefined data
89: 'undefined var' => @$undefined_var,
90:
91: // unset data
92: 'unset var' => @$unset_var,
93:
94: // resource
95: 'resource' => $file_handle
96: );
97:
98: $tz = timezone_open("Europe/London");
99: $timestamp_begin = mktime(0, 0, 0, 1, 1, 1975);
100:
101: foreach($inputs as $variation =>$timestamp_end) {
102: echo "\n-- $variation --\n";
103: $tran = timezone_transitions_get($tz, $timestamp_begin, $timestamp_end);
104: var_dump( gettype($tran) );
105: var_dump( count($tran) );
106: };
107:
108: // closing the resource
109: fclose( $file_handle );
110:
111: ?>
112: ===DONE===
113: --EXPECTF--
114: *** Testing timezone_transitions_get() : usage variation - unexpected values to first argument $timestamp_end ***
115:
116: -- int 0 --
117: string(5) "array"
118: int(1)
119:
120: -- int 1 --
121: string(5) "array"
122: int(1)
123:
124: -- int 12345 --
125: string(5) "array"
126: int(1)
127:
128: -- int -12345 --
129: string(5) "array"
130: int(1)
131:
132: -- float 10.5 --
133: string(5) "array"
134: int(1)
135:
136: -- float -10.5 --
137: string(5) "array"
138: int(1)
139:
140: -- float .5 --
141: string(5) "array"
142: int(1)
143:
144: -- empty array --
145:
146: Warning: timezone_transitions_get() expects parameter 3 to be long, array given in %s on line %d
147: string(7) "boolean"
148: int(1)
149:
150: -- int indexed array --
151:
152: Warning: timezone_transitions_get() expects parameter 3 to be long, array given in %s on line %d
153: string(7) "boolean"
154: int(1)
155:
156: -- associative array --
157:
158: Warning: timezone_transitions_get() expects parameter 3 to be long, array given in %s on line %d
159: string(7) "boolean"
160: int(1)
161:
162: -- nested arrays --
163:
164: Warning: timezone_transitions_get() expects parameter 3 to be long, array given in %s on line %d
165: string(7) "boolean"
166: int(1)
167:
168: -- uppercase NULL --
169: string(5) "array"
170: int(1)
171:
172: -- lowercase null --
173: string(5) "array"
174: int(1)
175:
176: -- lowercase true --
177: string(5) "array"
178: int(1)
179:
180: -- lowercase false --
181: string(5) "array"
182: int(1)
183:
184: -- uppercase TRUE --
185: string(5) "array"
186: int(1)
187:
188: -- uppercase FALSE --
189: string(5) "array"
190: int(1)
191:
192: -- empty string DQ --
193:
194: Warning: timezone_transitions_get() expects parameter 3 to be long, string given in %s on line %d
195: string(7) "boolean"
196: int(1)
197:
198: -- empty string SQ --
199:
200: Warning: timezone_transitions_get() expects parameter 3 to be long, string given in %s on line %d
201: string(7) "boolean"
202: int(1)
203:
204: -- string DQ --
205:
206: Warning: timezone_transitions_get() expects parameter 3 to be long, string given in %s on line %d
207: string(7) "boolean"
208: int(1)
209:
210: -- string SQ --
211:
212: Warning: timezone_transitions_get() expects parameter 3 to be long, string given in %s on line %d
213: string(7) "boolean"
214: int(1)
215:
216: -- mixed case string --
217:
218: Warning: timezone_transitions_get() expects parameter 3 to be long, string given in %s on line %d
219: string(7) "boolean"
220: int(1)
221:
222: -- heredoc --
223:
224: Warning: timezone_transitions_get() expects parameter 3 to be long, string given in %s on line %d
225: string(7) "boolean"
226: int(1)
227:
228: -- instance of classWithToString --
229:
230: Warning: timezone_transitions_get() expects parameter 3 to be long, object given in %s on line %d
231: string(7) "boolean"
232: int(1)
233:
234: -- instance of classWithoutToString --
235:
236: Warning: timezone_transitions_get() expects parameter 3 to be long, object given in %s on line %d
237: string(7) "boolean"
238: int(1)
239:
240: -- undefined var --
241: string(5) "array"
242: int(1)
243:
244: -- unset var --
245: string(5) "array"
246: int(1)
247:
248: -- resource --
249:
250: Warning: timezone_transitions_get() expects parameter 3 to be long, resource given in %s on line %d
251: string(7) "boolean"
252: int(1)
253: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>