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