1--TEST-- 2Test 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 10echo "*** 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; 18date_default_timezone_set("Asia/Calcutta"); 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' => -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 98foreach($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-- 111string(5) "08:56" 112float(8.944%d) 113int(28599) 114 115--int 1-- 116string(5) "08:56" 117float(8.944%d) 118int(28599) 119 120--int 12345-- 121string(5) "08:56" 122float(8.944%d) 123int(28599) 124 125--int -12345-- 126string(5) "08:56" 127float(8.944%d) 128int(28599) 129 130--float 10.5-- 131string(5) "08:56" 132float(8.944%d) 133int(28599) 134 135--float -10.5-- 136string(5) "08:56" 137float(8.944%d) 138int(28599) 139 140--float .5-- 141string(5) "08:56" 142float(8.944%d) 143int(28599) 144 145--empty array-- 146 147Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d 148bool(false) 149 150Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d 151bool(false) 152 153Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d 154bool(false) 155 156--int indexed array-- 157 158Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d 159bool(false) 160 161Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d 162bool(false) 163 164Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d 165bool(false) 166 167--associative array-- 168 169Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d 170bool(false) 171 172Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d 173bool(false) 174 175Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d 176bool(false) 177 178--nested arrays-- 179 180Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d 181bool(false) 182 183Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d 184bool(false) 185 186Warning: date_sunrise() expects parameter 1 to be long, array given in %s on line %d 187bool(false) 188 189--uppercase NULL-- 190string(5) "08:56" 191float(8.944%d) 192int(28599) 193 194--lowercase null-- 195string(5) "08:56" 196float(8.944%d) 197int(28599) 198 199--lowercase true-- 200string(5) "08:56" 201float(8.944%d) 202int(28599) 203 204--lowercase false-- 205string(5) "08:56" 206float(8.944%d) 207int(28599) 208 209--uppercase TRUE-- 210string(5) "08:56" 211float(8.944%d) 212int(28599) 213 214--uppercase FALSE-- 215string(5) "08:56" 216float(8.944%d) 217int(28599) 218 219--empty string DQ-- 220 221Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 222bool(false) 223 224Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 225bool(false) 226 227Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 228bool(false) 229 230--empty string SQ-- 231 232Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 233bool(false) 234 235Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 236bool(false) 237 238Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 239bool(false) 240 241--string DQ-- 242 243Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 244bool(false) 245 246Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 247bool(false) 248 249Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 250bool(false) 251 252--string SQ-- 253 254Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 255bool(false) 256 257Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 258bool(false) 259 260Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 261bool(false) 262 263--mixed case string-- 264 265Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 266bool(false) 267 268Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 269bool(false) 270 271Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 272bool(false) 273 274--heredoc-- 275 276Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 277bool(false) 278 279Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 280bool(false) 281 282Warning: date_sunrise() expects parameter 1 to be long, string given in %s on line %d 283bool(false) 284 285--instance of classWithToString-- 286 287Warning: date_sunrise() expects parameter 1 to be long, object given in %s on line %d 288bool(false) 289 290Warning: date_sunrise() expects parameter 1 to be long, object given in %s on line %d 291bool(false) 292 293Warning: date_sunrise() expects parameter 1 to be long, object given in %s on line %d 294bool(false) 295 296--instance of classWithoutToString-- 297 298Warning: date_sunrise() expects parameter 1 to be long, object given in %s on line %d 299bool(false) 300 301Warning: date_sunrise() expects parameter 1 to be long, object given in %s on line %d 302bool(false) 303 304Warning: date_sunrise() expects parameter 1 to be long, object given in %s on line %d 305bool(false) 306 307--undefined var-- 308string(5) "08:56" 309float(8.944%d) 310int(28599) 311 312--unset var-- 313string(5) "08:56" 314float(8.944%d) 315int(28599) 316===DONE=== 317