1--TEST--
2Test date_sunset() function : usage variation - Passing unexpected values to third argument latitude.
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
11echo "*** Testing date_sunset() : usage variation ***\n";
12
13// Initialise function arguments not being substituted (if any)
14date_default_timezone_set("Asia/Calcutta");
15$time = mktime(8, 8, 8, 8, 8, 2008);
16$longitude = 88.21;
17$zenith = 90;
18$gmt_offset = 5.5;
19
20//get an unset variable
21$unset_var = 10;
22unset ($unset_var);
23
24// define some classes
25class classWithToString
26{
27	public function __toString() {
28		return "Class A object";
29	}
30}
31
32class classWithoutToString
33{
34}
35
36// heredoc string
37$heredoc = <<<EOT
38hello world
39EOT;
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 latitude
92
93foreach($inputs as $key =>$value) {
94      echo "\n--$key--\n";
95      var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $value, $longitude, $zenith, $gmt_offset) );
96      var_dump( date_sunset($time, SUNFUNCS_RET_DOUBLE, $value, $longitude, $zenith, $gmt_offset) );
97      var_dump( date_sunset($time, SUNFUNCS_RET_TIMESTAMP, $value, $longitude, $zenith, $gmt_offset) );
98
99};
100
101?>
102===DONE===
103--EXPECTF--
104*** Testing date_sunset() : usage variation ***
105
106--int 0--
107string(5) "17:43"
108float(17.730%d)
109int(1218197630)
110
111--int 1--
112string(5) "17:44"
113float(17.749%d)
114int(1218197698)
115
116--int 12345--
117bool(false)
118bool(false)
119bool(false)
120
121--int -12345--
122string(5) "17:35"
123float(17.598%d)
124int(1218197155)
125
126--empty array--
127
128Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
129bool(false)
130
131Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
132bool(false)
133
134Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
135bool(false)
136
137--int indexed array--
138
139Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
140bool(false)
141
142Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
143bool(false)
144
145Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
146bool(false)
147
148--associative array--
149
150Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
151bool(false)
152
153Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
154bool(false)
155
156Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
157bool(false)
158
159--nested arrays--
160
161Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
162bool(false)
163
164Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
165bool(false)
166
167Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
168bool(false)
169
170--uppercase NULL--
171string(5) "17:43"
172float(17.730%d)
173int(1218197630)
174
175--lowercase null--
176string(5) "17:43"
177float(17.730%d)
178int(1218197630)
179
180--lowercase true--
181string(5) "17:44"
182float(17.749%d)
183int(1218197698)
184
185--lowercase false--
186string(5) "17:43"
187float(17.730%d)
188int(1218197630)
189
190--uppercase TRUE--
191string(5) "17:44"
192float(17.749%d)
193int(1218197698)
194
195--uppercase FALSE--
196string(5) "17:43"
197float(17.730%d)
198int(1218197630)
199
200--empty string DQ--
201
202Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
203bool(false)
204
205Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
206bool(false)
207
208Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
209bool(false)
210
211--empty string SQ--
212
213Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
214bool(false)
215
216Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
217bool(false)
218
219Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
220bool(false)
221
222--string DQ--
223
224Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
225bool(false)
226
227Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
228bool(false)
229
230Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
231bool(false)
232
233--string SQ--
234
235Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
236bool(false)
237
238Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
239bool(false)
240
241Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
242bool(false)
243
244--mixed case string--
245
246Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
247bool(false)
248
249Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
250bool(false)
251
252Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
253bool(false)
254
255--heredoc--
256
257Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
258bool(false)
259
260Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
261bool(false)
262
263Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
264bool(false)
265
266--instance of classWithToString--
267
268Warning: date_sunset() expects parameter 3 to be float, object given in %s on line %d
269bool(false)
270
271Warning: date_sunset() expects parameter 3 to be float, object given in %s on line %d
272bool(false)
273
274Warning: date_sunset() expects parameter 3 to be float, object given in %s on line %d
275bool(false)
276
277--instance of classWithoutToString--
278
279Warning: date_sunset() expects parameter 3 to be float, object given in %s on line %d
280bool(false)
281
282Warning: date_sunset() expects parameter 3 to be float, object given in %s on line %d
283bool(false)
284
285Warning: date_sunset() expects parameter 3 to be float, object given in %s on line %d
286bool(false)
287
288--undefined var--
289string(5) "17:43"
290float(17.730%d)
291int(1218197630)
292
293--unset var--
294string(5) "17:43"
295float(17.730%d)
296int(1218197630)
297===DONE===
298