Annotation of embedaddon/php/ext/date/tests/date_sunrise_variation3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test date_sunrise() function : usage variation - Passing unexpected values to third argument latitude.
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 function arguments not being substituted (if any)
13: date_default_timezone_set("Asia/Calcutta");
14: $time = mktime(8, 8, 8, 8, 8, 2008);
15: $longitude = -9;
16: $zenith = 90;
17: $gmt_offset = -5.5;
18:
19: //get an unset variable
20: $unset_var = 10;
21: unset ($unset_var);
22:
23: // define some classes
24: class classWithToString
25: {
26: public function __toString() {
27: return "Class A object";
28: }
29: }
30:
31: class classWithoutToString
32: {
33: }
34:
35: // heredoc string
36: $heredoc = <<<EOT
37: hello world
38: EOT;
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' => -12345,
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 latitude
91:
92: foreach($inputs as $key =>$value) {
93: echo "\n--$key--\n";
94: var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $value, $longitude, $zenith, $gmt_offset) );
95: var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, $value, $longitude, $zenith, $gmt_offset) );
96: var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $value, $longitude, $zenith, $gmt_offset) );
97: };
98: ?>
99: ===DONE===
100: --EXPECTF--
101: *** Testing date_sunrise() : usage variation ***
102:
103: --int 0--
104: string(5) "01:10"
105: float(1.174%d)
106: int(1218177627)
107:
108: --int 1--
109: string(5) "01:09"
110: float(1.155%d)
111: int(1218177558)
112:
113: --int 12345--
114: bool(false)
115: bool(false)
116: bool(false)
117:
118: --int -12345--
119: bool(false)
120: bool(false)
121: bool(false)
122:
123: --empty array--
124:
125: Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d
126: bool(false)
127:
128: Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d
129: bool(false)
130:
131: Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d
132: bool(false)
133:
134: --int indexed array--
135:
136: Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d
137: bool(false)
138:
139: Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d
140: bool(false)
141:
142: Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d
143: bool(false)
144:
145: --associative array--
146:
147: Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d
148: bool(false)
149:
150: Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d
151: bool(false)
152:
153: Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d
154: bool(false)
155:
156: --nested arrays--
157:
158: Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d
159: bool(false)
160:
161: Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d
162: bool(false)
163:
164: Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d
165: bool(false)
166:
167: --uppercase NULL--
168: string(5) "01:10"
169: float(1.174%d)
170: int(1218177627)
171:
172: --lowercase null--
173: string(5) "01:10"
174: float(1.174%d)
175: int(1218177627)
176:
177: --lowercase true--
178: string(5) "01:09"
179: float(1.155%d)
180: int(1218177558)
181:
182: --lowercase false--
183: string(5) "01:10"
184: float(1.174%d)
185: int(1218177627)
186:
187: --uppercase TRUE--
188: string(5) "01:09"
189: float(1.155%d)
190: int(1218177558)
191:
192: --uppercase FALSE--
193: string(5) "01:10"
194: float(1.174%d)
195: int(1218177627)
196:
197: --empty string DQ--
198:
199: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
200: bool(false)
201:
202: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
203: bool(false)
204:
205: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
206: bool(false)
207:
208: --empty string SQ--
209:
210: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
211: bool(false)
212:
213: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
214: bool(false)
215:
216: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
217: bool(false)
218:
219: --string DQ--
220:
221: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
222: bool(false)
223:
224: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
225: bool(false)
226:
227: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
228: bool(false)
229:
230: --string SQ--
231:
232: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
233: bool(false)
234:
235: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
236: bool(false)
237:
238: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
239: bool(false)
240:
241: --mixed case string--
242:
243: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
244: bool(false)
245:
246: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
247: bool(false)
248:
249: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
250: bool(false)
251:
252: --heredoc--
253:
254: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
255: bool(false)
256:
257: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
258: bool(false)
259:
260: Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d
261: bool(false)
262:
263: --instance of classWithToString--
264:
265: Warning: date_sunrise() expects parameter 3 to be double, object given in %s on line %d
266: bool(false)
267:
268: Warning: date_sunrise() expects parameter 3 to be double, object given in %s on line %d
269: bool(false)
270:
271: Warning: date_sunrise() expects parameter 3 to be double, object given in %s on line %d
272: bool(false)
273:
274: --instance of classWithoutToString--
275:
276: Warning: date_sunrise() expects parameter 3 to be double, object given in %s on line %d
277: bool(false)
278:
279: Warning: date_sunrise() expects parameter 3 to be double, object given in %s on line %d
280: bool(false)
281:
282: Warning: date_sunrise() expects parameter 3 to be double, object given in %s on line %d
283: bool(false)
284:
285: --undefined var--
286: string(5) "01:10"
287: float(1.174%d)
288: int(1218177627)
289:
290: --unset var--
291: string(5) "01:10"
292: float(1.174%d)
293: int(1218177627)
294: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>