Annotation of embedaddon/php/ext/date/tests/date_sunset_variation6.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test date_sunset() function : usage variation - Passing unexpected values to sixth argument gmt_offset.
3: --FILE--
4: <?php
5: /* Prototype : mixed date_sunset(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
6: * Description: Returns time of sunset for a given day and location
7: * Source code: ext/date/php_date.c
8: * Alias to functions:
9: */
10:
11: echo "*** Testing date_sunset() : usage variation ***\n";
12:
13: // Initialise function arguments not being substituted (if any)
14: date_default_timezone_set("Asia/Calcutta");
15: $time = mktime(8, 8, 8, 8, 8, 2008);
16: $longitude = 88.21;
17: $latitude = 22.34;
18: $zenith = 90;
19:
20: //get an unset variable
21: $unset_var = 10;
22: unset ($unset_var);
23:
24: // define some classes
25: class classWithToString
26: {
27: public function __toString() {
28: return "Class A object";
29: }
30: }
31:
32: class classWithoutToString
33: {
34: }
35:
36: // heredoc string
37: $heredoc = <<<EOT
38: hello world
39: EOT;
40:
41: // add arrays
42: $index_array = array (1, 2, 3);
43: $assoc_array = array ('one' => 1, 'two' => 2);
44:
45: //array of values to iterate over
46: $inputs = array(
47:
48: // int data
49: 'int 0' => 0,
50: 'int 1' => 1,
51: 'int 12345' => 12345,
52: 'int -12345' => -2345,
53:
54: // array data
55: 'empty array' => array(),
56: 'int indexed array' => $index_array,
57: 'associative array' => $assoc_array,
58: 'nested arrays' => array('foo', $index_array, $assoc_array),
59:
60: // null data
61: 'uppercase NULL' => NULL,
62: 'lowercase null' => null,
63:
64: // boolean data
65: 'lowercase true' => true,
66: 'lowercase false' =>false,
67: 'uppercase TRUE' =>TRUE,
68: 'uppercase FALSE' =>FALSE,
69:
70: // empty data
71: 'empty string DQ' => "",
72: 'empty string SQ' => '',
73:
74: // string data
75: 'string DQ' => "string",
76: 'string SQ' => 'string',
77: 'mixed case string' => "sTrInG",
78: 'heredoc' => $heredoc,
79:
80: // object data
81: 'instance of classWithToString' => new classWithToString(),
82: 'instance of classWithoutToString' => new classWithoutToString(),
83:
84: // undefined data
85: 'undefined var' => @$undefined_var,
86:
87: // unset data
88: 'unset var' => @$unset_var,
89: );
90:
91: // loop through each element of the array for gmt_offset
92:
93: foreach($inputs as $key =>$value) {
94: echo "\n--$key--\n";
95: var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $latitude, $longitude, $zenith, $value) );
96: var_dump( date_sunset($time, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, $zenith, $value) );
97: var_dump( date_sunset($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, $zenith, $value) );
98: };
99:
100: ?>
101: ===DONE===
102: --EXPECTF--
103: *** Testing date_sunset() : usage variation ***
104:
105: --int 0--
106: string(5) "12:40"
107: float(12.681%d)
108: int(1218199253)
109:
110: --int 1--
111: string(5) "13:40"
112: float(13.681%d)
113: int(1218199253)
114:
115: --int 12345--
116: string(5) "21:40"
117: float(21.681%d)
118: int(1218199253)
119:
120: --int -12345--
121: string(5) "19:40"
122: float(19.681%d)
123: int(1218199253)
124:
125: --empty array--
126:
127: Warning: date_sunset() expects parameter 6 to be double, array given in %s on line %d
128: bool(false)
129:
130: Warning: date_sunset() expects parameter 6 to be double, array given in %s on line %d
131: bool(false)
132:
133: Warning: date_sunset() expects parameter 6 to be double, array given in %s on line %d
134: bool(false)
135:
136: --int indexed array--
137:
138: Warning: date_sunset() expects parameter 6 to be double, array given in %s on line %d
139: bool(false)
140:
141: Warning: date_sunset() expects parameter 6 to be double, array given in %s on line %d
142: bool(false)
143:
144: Warning: date_sunset() expects parameter 6 to be double, array given in %s on line %d
145: bool(false)
146:
147: --associative array--
148:
149: Warning: date_sunset() expects parameter 6 to be double, array given in %s on line %d
150: bool(false)
151:
152: Warning: date_sunset() expects parameter 6 to be double, array given in %s on line %d
153: bool(false)
154:
155: Warning: date_sunset() expects parameter 6 to be double, array given in %s on line %d
156: bool(false)
157:
158: --nested arrays--
159:
160: Warning: date_sunset() expects parameter 6 to be double, array given in %s on line %d
161: bool(false)
162:
163: Warning: date_sunset() expects parameter 6 to be double, array given in %s on line %d
164: bool(false)
165:
166: Warning: date_sunset() expects parameter 6 to be double, array given in %s on line %d
167: bool(false)
168:
169: --uppercase NULL--
170: string(5) "12:40"
171: float(12.681%d)
172: int(1218199253)
173:
174: --lowercase null--
175: string(5) "12:40"
176: float(12.681%d)
177: int(1218199253)
178:
179: --lowercase true--
180: string(5) "13:40"
181: float(13.681%d)
182: int(1218199253)
183:
184: --lowercase false--
185: string(5) "12:40"
186: float(12.681%d)
187: int(1218199253)
188:
189: --uppercase TRUE--
190: string(5) "13:40"
191: float(13.681%d)
192: int(1218199253)
193:
194: --uppercase FALSE--
195: string(5) "12:40"
196: float(12.681%d)
197: int(1218199253)
198:
199: --empty string DQ--
200:
201: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
202: bool(false)
203:
204: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
205: bool(false)
206:
207: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
208: bool(false)
209:
210: --empty string SQ--
211:
212: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
213: bool(false)
214:
215: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
216: bool(false)
217:
218: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
219: bool(false)
220:
221: --string DQ--
222:
223: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
224: bool(false)
225:
226: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
227: bool(false)
228:
229: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
230: bool(false)
231:
232: --string SQ--
233:
234: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
235: bool(false)
236:
237: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
238: bool(false)
239:
240: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
241: bool(false)
242:
243: --mixed case string--
244:
245: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
246: bool(false)
247:
248: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
249: bool(false)
250:
251: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
252: bool(false)
253:
254: --heredoc--
255:
256: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
257: bool(false)
258:
259: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
260: bool(false)
261:
262: Warning: date_sunset() expects parameter 6 to be double, string given in %s on line %d
263: bool(false)
264:
265: --instance of classWithToString--
266:
267: Warning: date_sunset() expects parameter 6 to be double, object given in %s on line %d
268: bool(false)
269:
270: Warning: date_sunset() expects parameter 6 to be double, object given in %s on line %d
271: bool(false)
272:
273: Warning: date_sunset() expects parameter 6 to be double, object given in %s on line %d
274: bool(false)
275:
276: --instance of classWithoutToString--
277:
278: Warning: date_sunset() expects parameter 6 to be double, object given in %s on line %d
279: bool(false)
280:
281: Warning: date_sunset() expects parameter 6 to be double, object given in %s on line %d
282: bool(false)
283:
284: Warning: date_sunset() expects parameter 6 to be double, object given in %s on line %d
285: bool(false)
286:
287: --undefined var--
288: string(5) "12:40"
289: float(12.681%d)
290: int(1218199253)
291:
292: --unset var--
293: string(5) "12:40"
294: float(12.681%d)
295: int(1218199253)
296: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>