1--TEST--
2Test date_sunrise() function : usage variation - Passing unexpected values to second argument format.
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
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$latitude = 38.4;
17$longitude = -9;
18$zenith = 90;
19$gmt_offset = 1;
20
21//get an unset variable
22$unset_var = 10;
23unset ($unset_var);
24
25// define some classes
26class classWithToString
27{
28	public function __toString() {
29		return "Class A object";
30	}
31}
32
33class classWithoutToString
34{
35}
36
37// heredoc string
38$heredoc = <<<EOT
39hello world
40EOT;
41
42// add arrays
43$index_array = array (1, 2, 3);
44$assoc_array = array ('one' => 1, 'two' => 2);
45
46//array of values to iterate over
47$inputs = array(
48
49      // float data
50      'float 10.5' => 10.5,
51      'float -10.5' => -10.5,
52      'float 12.3456789000e10' => 12.3456789000e10,
53      'float -12.3456789000e10' => -12.3456789000e10,
54      'float .5' => .5,
55
56      // array data
57      'empty array' => array(),
58      'int indexed array' => $index_array,
59      'associative array' => $assoc_array,
60      'nested arrays' => array('foo', $index_array, $assoc_array),
61
62      // null data
63      'uppercase NULL' => NULL,
64      'lowercase null' => null,
65
66      // boolean data
67      'lowercase true' => true,
68      'lowercase false' =>false,
69      'uppercase TRUE' =>TRUE,
70      'uppercase FALSE' =>FALSE,
71
72      // empty data
73      'empty string DQ' => "",
74      'empty string SQ' => '',
75
76      // string data
77      'string DQ' => "string",
78      'string SQ' => 'string',
79      'mixed case string' => "sTrInG",
80      'heredoc' => $heredoc,
81
82      // object data
83      'instance of classWithToString' => new classWithToString(),
84      'instance of classWithoutToString' => new classWithoutToString(),
85
86      // undefined data
87      'undefined var' => @$undefined_var,
88
89      // unset data
90      'unset var' => @$unset_var,
91);
92
93// loop through each element of the array for format
94
95foreach($inputs as $key =>$value) {
96      echo "\n--$key--\n";
97      var_dump( date_sunrise($time, $value, $latitude, $longitude, $zenith, $gmt_offset) );
98};
99
100?>
101===DONE===
102--EXPECTF--
103*** Testing date_sunrise() : usage variation ***
104
105--float 10.5--
106
107Warning: date_sunrise(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
108bool(false)
109
110--float -10.5--
111
112Warning: date_sunrise(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
113bool(false)
114
115--float 12.3456789000e10--
116
117Warning: date_sunrise(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
118bool(false)
119
120--float -12.3456789000e10--
121
122Warning: date_sunrise(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
123bool(false)
124
125--float .5--
126int(1218174483)
127
128--empty array--
129
130Warning: date_sunrise() expects parameter 2 to be long, array given in %s on line %d
131bool(false)
132
133--int indexed array--
134
135Warning: date_sunrise() expects parameter 2 to be long, array given in %s on line %d
136bool(false)
137
138--associative array--
139
140Warning: date_sunrise() expects parameter 2 to be long, array given in %s on line %d
141bool(false)
142
143--nested arrays--
144
145Warning: date_sunrise() expects parameter 2 to be long, array given in %s on line %d
146bool(false)
147
148--uppercase NULL--
149int(1218174483)
150
151--lowercase null--
152int(1218174483)
153
154--lowercase true--
155string(5) "06:48"
156
157--lowercase false--
158int(1218174483)
159
160--uppercase TRUE--
161string(5) "06:48"
162
163--uppercase FALSE--
164int(1218174483)
165
166--empty string DQ--
167
168Warning: date_sunrise() expects parameter 2 to be long, string given in %s on line %d
169bool(false)
170
171--empty string SQ--
172
173Warning: date_sunrise() expects parameter 2 to be long, string given in %s on line %d
174bool(false)
175
176--string DQ--
177
178Warning: date_sunrise() expects parameter 2 to be long, string given in %s on line %d
179bool(false)
180
181--string SQ--
182
183Warning: date_sunrise() expects parameter 2 to be long, string given in %s on line %d
184bool(false)
185
186--mixed case string--
187
188Warning: date_sunrise() expects parameter 2 to be long, string given in %s on line %d
189bool(false)
190
191--heredoc--
192
193Warning: date_sunrise() expects parameter 2 to be long, string given in %s on line %d
194bool(false)
195
196--instance of classWithToString--
197
198Warning: date_sunrise() expects parameter 2 to be long, object given in %s on line %d
199bool(false)
200
201--instance of classWithoutToString--
202
203Warning: date_sunrise() expects parameter 2 to be long, object given in %s on line %d
204bool(false)
205
206--undefined var--
207int(1218174483)
208
209--unset var--
210int(1218174483)
211===DONE===
212