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