Annotation of embedaddon/php/ext/date/tests/date_sunrise_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
11: echo "*** Testing date_sunrise() : 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: $latitude = 38.4;
17: $longitude = -9;
18: $zenith = 90;
19: $gmt_offset = 1;
20:
21: //get an unset variable
22: $unset_var = 10;
23: unset ($unset_var);
24:
25: // define some classes
26: class classWithToString
27: {
28: public function __toString() {
29: return "Class A object";
30: }
31: }
32:
33: class classWithoutToString
34: {
35: }
36:
37: // heredoc string
38: $heredoc = <<<EOT
39: hello world
40: EOT;
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:
95: foreach($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:
107: Warning: date_sunrise(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
108: bool(false)
109:
110: --float -10.5--
111:
112: Warning: date_sunrise(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
113: bool(false)
114:
115: --float 12.3456789000e10--
116:
117: Warning: date_sunrise(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
118: bool(false)
119:
120: --float -12.3456789000e10--
121:
122: Warning: date_sunrise(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
123: bool(false)
124:
125: --float .5--
126: int(1218174483)
127:
128: --empty array--
129:
130: Warning: date_sunrise() expects parameter 2 to be long, array given in %s on line %d
131: bool(false)
132:
133: --int indexed array--
134:
135: Warning: date_sunrise() expects parameter 2 to be long, array given in %s on line %d
136: bool(false)
137:
138: --associative array--
139:
140: Warning: date_sunrise() expects parameter 2 to be long, array given in %s on line %d
141: bool(false)
142:
143: --nested arrays--
144:
145: Warning: date_sunrise() expects parameter 2 to be long, array given in %s on line %d
146: bool(false)
147:
148: --uppercase NULL--
149: int(1218174483)
150:
151: --lowercase null--
152: int(1218174483)
153:
154: --lowercase true--
155: string(5) "06:48"
156:
157: --lowercase false--
158: int(1218174483)
159:
160: --uppercase TRUE--
161: string(5) "06:48"
162:
163: --uppercase FALSE--
164: int(1218174483)
165:
166: --empty string DQ--
167:
168: Warning: date_sunrise() expects parameter 2 to be long, string given in %s on line %d
169: bool(false)
170:
171: --empty string SQ--
172:
173: Warning: date_sunrise() expects parameter 2 to be long, string given in %s on line %d
174: bool(false)
175:
176: --string DQ--
177:
178: Warning: date_sunrise() expects parameter 2 to be long, string given in %s on line %d
179: bool(false)
180:
181: --string SQ--
182:
183: Warning: date_sunrise() expects parameter 2 to be long, string given in %s on line %d
184: bool(false)
185:
186: --mixed case string--
187:
188: Warning: date_sunrise() expects parameter 2 to be long, string given in %s on line %d
189: bool(false)
190:
191: --heredoc--
192:
193: Warning: date_sunrise() expects parameter 2 to be long, string given in %s on line %d
194: bool(false)
195:
196: --instance of classWithToString--
197:
198: Warning: date_sunrise() expects parameter 2 to be long, object given in %s on line %d
199: bool(false)
200:
201: --instance of classWithoutToString--
202:
203: Warning: date_sunrise() expects parameter 2 to be long, object given in %s on line %d
204: bool(false)
205:
206: --undefined var--
207: int(1218174483)
208:
209: --unset var--
210: int(1218174483)
211: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>