Annotation of embedaddon/php/ext/date/tests/date_sunrise_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test date_sunrise() function : usage variation - Passing unexpected values to first argument time.
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: */
9:
10: echo "*** Testing date_sunrise() : usage variation ***\n";
11:
12: //Initialise the variables
13: $latitude = 38.4;
14: $longitude = -9;
15: $zenith = 90;
16: $gmt_offset = 1;
17: $format = SUNFUNCS_RET_STRING;
18: date_default_timezone_set("Asia/Calcutta");
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' => -12345,
53:
54: // float data
55: 'float 10.5' => 10.5,
56: 'float -10.5' => -10.5,
57: 'float .5' => .5,
58:
59: // array data
60: 'empty array' => array(),
61: 'int indexed array' => $index_array,
62: 'associative array' => $assoc_array,
63: 'nested arrays' => array('foo', $index_array, $assoc_array),
64:
65: // null data
66: 'uppercase NULL' => NULL,
67: 'lowercase null' => null,
68:
69: // boolean data
70: 'lowercase true' => true,
71: 'lowercase false' =>false,
72: 'uppercase TRUE' =>TRUE,
73: 'uppercase FALSE' =>FALSE,
74:
75: // empty data
76: 'empty string DQ' => "",
77: 'empty string SQ' => '',
78:
79: // string data
80: 'string DQ' => "string",
81: 'string SQ' => 'string',
82: 'mixed case string' => "sTrInG",
83: 'heredoc' => $heredoc,
84:
85: // object data
86: 'instance of classWithToString' => new classWithToString(),
87: 'instance of classWithoutToString' => new classWithoutToString(),
88:
89: // undefined data
90: 'undefined var' => @$undefined_var,
91:
92: // unset data
93: 'unset var' => @$unset_var,
94: );
95:
96: // loop through each element of the array for time
97:
98: foreach($inputs as $key =>$value) {
99: echo "\n--$key--\n";
100: var_dump( date_sunrise($value, SUNFUNCS_RET_STRING, $latitude, $longitude, $zenith, $gmt_offset) );
101: var_dump( date_sunrise($value, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, $zenith, $gmt_offset) );
102: var_dump( date_sunrise($value, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, $zenith, $gmt_offset) );
103: };
104:
105: ?>
106: ===DONE===
107: --EXPECTF--
108: *** Testing date_sunrise() : usage variation ***
109:
110: --int 0--
111: string(5) "08:56"
112: float(8.944%d)
113: int(28599)
114:
115: --int 1--
116: string(5) "08:56"
117: float(8.944%d)
118: int(28599)
119:
120: --int 12345--
121: string(5) "08:56"
122: float(8.944%d)
123: int(28599)
124:
125: --int -12345--
126: string(5) "08:56"
127: float(8.944%d)
128: int(28599)
129:
130: --float 10.5--
131: string(5) "08:56"
132: float(8.944%d)
133: int(28599)
134:
135: --float -10.5--
136: string(5) "08:56"
137: float(8.944%d)
138: int(28599)
139:
140: --float .5--
141: string(5) "08:56"
142: float(8.944%d)
143: int(28599)
144:
145: --empty array--
146:
147: Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d
148: bool(false)
149:
150: Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d
151: bool(false)
152:
153: Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d
154: bool(false)
155:
156: --int indexed array--
157:
158: Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d
159: bool(false)
160:
161: Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d
162: bool(false)
163:
164: Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d
165: bool(false)
166:
167: --associative array--
168:
169: Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d
170: bool(false)
171:
172: Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d
173: bool(false)
174:
175: Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d
176: bool(false)
177:
178: --nested arrays--
179:
180: Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d
181: bool(false)
182:
183: Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d
184: bool(false)
185:
186: Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d
187: bool(false)
188:
189: --uppercase NULL--
190: string(5) "08:56"
191: float(8.944%d)
192: int(28599)
193:
194: --lowercase null--
195: string(5) "08:56"
196: float(8.944%d)
197: int(28599)
198:
199: --lowercase true--
200: string(5) "08:56"
201: float(8.944%d)
202: int(28599)
203:
204: --lowercase false--
205: string(5) "08:56"
206: float(8.944%d)
207: int(28599)
208:
209: --uppercase TRUE--
210: string(5) "08:56"
211: float(8.944%d)
212: int(28599)
213:
214: --uppercase FALSE--
215: string(5) "08:56"
216: float(8.944%d)
217: int(28599)
218:
219: --empty string DQ--
220:
221: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
222: bool(false)
223:
224: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
225: bool(false)
226:
227: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
228: bool(false)
229:
230: --empty string SQ--
231:
232: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
233: bool(false)
234:
235: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
236: bool(false)
237:
238: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
239: bool(false)
240:
241: --string DQ--
242:
243: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
244: bool(false)
245:
246: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
247: bool(false)
248:
249: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
250: bool(false)
251:
252: --string SQ--
253:
254: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
255: bool(false)
256:
257: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
258: bool(false)
259:
260: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
261: bool(false)
262:
263: --mixed case string--
264:
265: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
266: bool(false)
267:
268: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
269: bool(false)
270:
271: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
272: bool(false)
273:
274: --heredoc--
275:
276: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
277: bool(false)
278:
279: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
280: bool(false)
281:
282: Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d
283: bool(false)
284:
285: --instance of classWithToString--
286:
287: Warning: date_sunrise() expects parameter 1 to be long, object given in %s on line %d
288: bool(false)
289:
290: Warning: date_sunrise() expects parameter 1 to be long, object given in %s on line %d
291: bool(false)
292:
293: Warning: date_sunrise() expects parameter 1 to be long, object given in %s on line %d
294: bool(false)
295:
296: --instance of classWithoutToString--
297:
298: Warning: date_sunrise() expects parameter 1 to be long, object given in %s on line %d
299: bool(false)
300:
301: Warning: date_sunrise() expects parameter 1 to be long, object given in %s on line %d
302: bool(false)
303:
304: Warning: date_sunrise() expects parameter 1 to be long, object given in %s on line %d
305: bool(false)
306:
307: --undefined var--
308: string(5) "08:56"
309: float(8.944%d)
310: int(28599)
311:
312: --unset var--
313: string(5) "08:56"
314: float(8.944%d)
315: int(28599)
316: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>