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