Annotation of embedaddon/php/ext/date/tests/date_sunset_variation3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
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: $zenith = 90;
18: $gmt_offset = 5.5;
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 latitude
92:
93: foreach($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--
107: string(5) "17:43"
108: float(17.730%d)
109: int(1218197630)
110:
111: --int 1--
112: string(5) "17:44"
113: float(17.749%d)
114: int(1218197698)
115:
116: --int 12345--
117: bool(false)
118: bool(false)
119: bool(false)
120:
121: --int -12345--
122: string(5) "17:35"
123: float(17.598%d)
124: int(1218197155)
125:
126: --empty array--
127:
128: Warning: date_sunset() expects parameter 3 to be double, array given in %s on line %d
129: bool(false)
130:
131: Warning: date_sunset() expects parameter 3 to be double, array given in %s on line %d
132: bool(false)
133:
134: Warning: date_sunset() expects parameter 3 to be double, array given in %s on line %d
135: bool(false)
136:
137: --int indexed array--
138:
139: Warning: date_sunset() expects parameter 3 to be double, array given in %s on line %d
140: bool(false)
141:
142: Warning: date_sunset() expects parameter 3 to be double, array given in %s on line %d
143: bool(false)
144:
145: Warning: date_sunset() expects parameter 3 to be double, array given in %s on line %d
146: bool(false)
147:
148: --associative array--
149:
150: Warning: date_sunset() expects parameter 3 to be double, array given in %s on line %d
151: bool(false)
152:
153: Warning: date_sunset() expects parameter 3 to be double, array given in %s on line %d
154: bool(false)
155:
156: Warning: date_sunset() expects parameter 3 to be double, array given in %s on line %d
157: bool(false)
158:
159: --nested arrays--
160:
161: Warning: date_sunset() expects parameter 3 to be double, array given in %s on line %d
162: bool(false)
163:
164: Warning: date_sunset() expects parameter 3 to be double, array given in %s on line %d
165: bool(false)
166:
167: Warning: date_sunset() expects parameter 3 to be double, array given in %s on line %d
168: bool(false)
169:
170: --uppercase NULL--
171: string(5) "17:43"
172: float(17.730%d)
173: int(1218197630)
174:
175: --lowercase null--
176: string(5) "17:43"
177: float(17.730%d)
178: int(1218197630)
179:
180: --lowercase true--
181: string(5) "17:44"
182: float(17.749%d)
183: int(1218197698)
184:
185: --lowercase false--
186: string(5) "17:43"
187: float(17.730%d)
188: int(1218197630)
189:
190: --uppercase TRUE--
191: string(5) "17:44"
192: float(17.749%d)
193: int(1218197698)
194:
195: --uppercase FALSE--
196: string(5) "17:43"
197: float(17.730%d)
198: int(1218197630)
199:
200: --empty string DQ--
201:
202: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
203: bool(false)
204:
205: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
206: bool(false)
207:
208: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
209: bool(false)
210:
211: --empty string SQ--
212:
213: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
214: bool(false)
215:
216: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
217: bool(false)
218:
219: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
220: bool(false)
221:
222: --string DQ--
223:
224: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
225: bool(false)
226:
227: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
228: bool(false)
229:
230: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
231: bool(false)
232:
233: --string SQ--
234:
235: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
236: bool(false)
237:
238: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
239: bool(false)
240:
241: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
242: bool(false)
243:
244: --mixed case string--
245:
246: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
247: bool(false)
248:
249: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
250: bool(false)
251:
252: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
253: bool(false)
254:
255: --heredoc--
256:
257: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
258: bool(false)
259:
260: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
261: bool(false)
262:
263: Warning: date_sunset() expects parameter 3 to be double, string given in %s on line %d
264: bool(false)
265:
266: --instance of classWithToString--
267:
268: Warning: date_sunset() expects parameter 3 to be double, object given in %s on line %d
269: bool(false)
270:
271: Warning: date_sunset() expects parameter 3 to be double, object given in %s on line %d
272: bool(false)
273:
274: Warning: date_sunset() expects parameter 3 to be double, object given in %s on line %d
275: bool(false)
276:
277: --instance of classWithoutToString--
278:
279: Warning: date_sunset() expects parameter 3 to be double, object given in %s on line %d
280: bool(false)
281:
282: Warning: date_sunset() expects parameter 3 to be double, object given in %s on line %d
283: bool(false)
284:
285: Warning: date_sunset() expects parameter 3 to be double, object given in %s on line %d
286: bool(false)
287:
288: --undefined var--
289: string(5) "17:43"
290: float(17.730%d)
291: int(1218197630)
292:
293: --unset var--
294: string(5) "17:43"
295: float(17.730%d)
296: int(1218197630)
297: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>