1--TEST--
2Test date_sunrise() function : usage variation - Passing unexpected values to second argument format.
3--SKIPIF--
4<?php if (PHP_INT_SIZE != 4) echo "skip this test is for 32-bit only"; ?>
5--FILE--
6<?php
7/* Prototype  : mixed date_sunrise(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
8 * Description: Returns time of sunrise for a given day and location
9 * Source code: ext/date/php_date.c
10 * Alias to functions:
11 */
12
13echo "*** Testing date_sunrise() : usage variation ***\n";
14
15// Initialise function arguments not being substituted (if any)
16date_default_timezone_set("Asia/Calcutta");
17$time = mktime(8, 8, 8, 8, 8, 2008);
18$latitude = 38.4;
19$longitude = -9;
20$zenith = 90;
21$gmt_offset = 1;
22
23//get an unset variable
24$unset_var = 10;
25unset ($unset_var);
26
27// define some classes
28class classWithToString
29{
30	public function __toString() {
31		return "Class A object";
32	}
33}
34
35class classWithoutToString
36{
37}
38
39// heredoc string
40$heredoc = <<<EOT
41hello world
42EOT;
43
44// add arrays
45$index_array = array (1, 2, 3);
46$assoc_array = array ('one' => 1, 'two' => 2);
47
48//array of values to iterate over
49$inputs = array(
50
51      // float data
52      'float 10.5' => 10.5,
53      'float -10.5' => -10.5,
54      'float 12.3456789000e10' => 12.3456789000e10,
55      'float -12.3456789000e10' => -12.3456789000e10,
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
95// loop through each element of the array for format
96
97foreach($inputs as $key =>$value) {
98      echo "\n--$key--\n";
99      var_dump( date_sunrise($time, $value, $latitude, $longitude, $zenith, $gmt_offset) );
100};
101
102?>
103===DONE===
104--EXPECTF--
105*** Testing date_sunrise() : usage variation ***
106
107--float 10.5--
108
109Warning: date_sunrise(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
110bool(false)
111
112--float -10.5--
113
114Warning: date_sunrise(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
115bool(false)
116
117--float 12.3456789000e10--
118
119Warning: date_sunrise() expects parameter 2 to be integer, float given in %s on line %d
120bool(false)
121
122--float -12.3456789000e10--
123
124Warning: date_sunrise() expects parameter 2 to be integer, float given in %s on line %d
125bool(false)
126
127--float .5--
128int(1218174483)
129
130--empty array--
131
132Warning: date_sunrise() expects parameter 2 to be integer, array given in %s on line %d
133bool(false)
134
135--int indexed array--
136
137Warning: date_sunrise() expects parameter 2 to be integer, array given in %s on line %d
138bool(false)
139
140--associative array--
141
142Warning: date_sunrise() expects parameter 2 to be integer, array given in %s on line %d
143bool(false)
144
145--nested arrays--
146
147Warning: date_sunrise() expects parameter 2 to be integer, array given in %s on line %d
148bool(false)
149
150--uppercase NULL--
151int(1218174483)
152
153--lowercase null--
154int(1218174483)
155
156--lowercase true--
157string(5) "06:48"
158
159--lowercase false--
160int(1218174483)
161
162--uppercase TRUE--
163string(5) "06:48"
164
165--uppercase FALSE--
166int(1218174483)
167
168--empty string DQ--
169
170Warning: date_sunrise() expects parameter 2 to be integer, string given in %s on line %d
171bool(false)
172
173--empty string SQ--
174
175Warning: date_sunrise() expects parameter 2 to be integer, string given in %s on line %d
176bool(false)
177
178--string DQ--
179
180Warning: date_sunrise() expects parameter 2 to be integer, string given in %s on line %d
181bool(false)
182
183--string SQ--
184
185Warning: date_sunrise() expects parameter 2 to be integer, string given in %s on line %d
186bool(false)
187
188--mixed case string--
189
190Warning: date_sunrise() expects parameter 2 to be integer, string given in %s on line %d
191bool(false)
192
193--heredoc--
194
195Warning: date_sunrise() expects parameter 2 to be integer, string given in %s on line %d
196bool(false)
197
198--instance of classWithToString--
199
200Warning: date_sunrise() expects parameter 2 to be integer, object given in %s on line %d
201bool(false)
202
203--instance of classWithoutToString--
204
205Warning: date_sunrise() expects parameter 2 to be integer, object given in %s on line %d
206bool(false)
207
208--undefined var--
209int(1218174483)
210
211--unset var--
212int(1218174483)
213===DONE===
214