1--TEST-- 2Test date_sun_info() function : error variations - Pass unexpected values for latitude argument 3--FILE-- 4<?php 5/* Prototype : array date_sun_info ( int $time , float $latitude , float $longitude ) 6 * Description: Returns an array with information about sunset/sunrise and twilight begin/end. 7 * Source code: ext/standard/data/php_date.c 8 */ 9 10date_default_timezone_set("UTC"); 11 12echo "*** Testing date_sun_info() : usage variations ***\n"; 13 14//get an unset variable 15$unset_var = 10; 16unset ($unset_var); 17 18// heredoc string 19$heredoc = <<<EOT 20abc 21xyz 22EOT; 23 24// get a resource variable 25$fp = fopen(__FILE__, "r"); 26 27$inputs = array( 28 // int data 29/*1*/ 0, 30 1, 31 12345, 32 -2345, 33 34 // float data 35/*5*/ 10.5, 36 -10.5, 37 12.3456789000e10, 38 12.3456789000E-10, 39 .5, 40 41 // null data 42/*10*/ NULL, 43 null, 44 45 // boolean data 46/*12*/ true, 47 false, 48 TRUE, 49 FALSE, 50 51 // empty data 52/*16*/ "", 53 '', 54 array(), 55 56 // string data 57/*19*/ "abcxyz", 58 'abcxyz', 59 $heredoc, 60 61 // undefined data 62/*22*/ @$undefined_var, 63 64 // unset data 65/*23*/ @$unset_var, 66 67 // resource variable 68/*24*/ $fp 69); 70 71// loop through each element of $inputs to check the behaviour of date_sun_info() 72$iterator = 1; 73foreach($inputs as $input) { 74 echo "\n-- Iteration $iterator --\n"; 75 var_dump(date_sun_info(strtotime("2006-12-12"), $input, 35.2333)); 76 $iterator++; 77}; 78 79?> 80===Done=== 81--EXPECTF-- 82*** Testing date_sun_info() : usage variations *** 83 84-- Iteration 1 -- 85array(9) { 86 ["sunrise"]=> 87 int(1165894152) 88 ["sunset"]=> 89 int(1165937798) 90 ["transit"]=> 91 int(1165915975) 92 ["civil_twilight_begin"]=> 93 int(1165892809) 94 ["civil_twilight_end"]=> 95 int(1165939141) 96 ["nautical_twilight_begin"]=> 97 int(1165891239) 98 ["nautical_twilight_end"]=> 99 int(1165940710) 100 ["astronomical_twilight_begin"]=> 101 int(1165889663) 102 ["astronomical_twilight_end"]=> 103 int(1165942287) 104} 105 106-- Iteration 2 -- 107array(9) { 108 ["sunrise"]=> 109 int(1165894254) 110 ["sunset"]=> 111 int(1165937695) 112 ["transit"]=> 113 int(1165915975) 114 ["civil_twilight_begin"]=> 115 int(1165892911) 116 ["civil_twilight_end"]=> 117 int(1165939038) 118 ["nautical_twilight_begin"]=> 119 int(1165891344) 120 ["nautical_twilight_end"]=> 121 int(1165940606) 122 ["astronomical_twilight_begin"]=> 123 int(1165889771) 124 ["astronomical_twilight_end"]=> 125 int(1165942179) 126} 127 128-- Iteration 3 -- 129array(9) { 130 ["sunrise"]=> 131 bool(true) 132 ["sunset"]=> 133 bool(true) 134 ["transit"]=> 135 int(1165915975) 136 ["civil_twilight_begin"]=> 137 bool(true) 138 ["civil_twilight_end"]=> 139 bool(true) 140 ["nautical_twilight_begin"]=> 141 int(1165883331) 142 ["nautical_twilight_end"]=> 143 int(1165948619) 144 ["astronomical_twilight_begin"]=> 145 int(1165890260) 146 ["astronomical_twilight_end"]=> 147 int(1165941690) 148} 149 150-- Iteration 4 -- 151array(9) { 152 ["sunrise"]=> 153 int(1165894085) 154 ["sunset"]=> 155 int(1165937865) 156 ["transit"]=> 157 int(1165915975) 158 ["civil_twilight_begin"]=> 159 int(1165895431) 160 ["civil_twilight_end"]=> 161 int(1165936519) 162 ["nautical_twilight_begin"]=> 163 int(1165896998) 164 ["nautical_twilight_end"]=> 165 int(1165934952) 166 ["astronomical_twilight_begin"]=> 167 int(1165898564) 168 ["astronomical_twilight_end"]=> 169 int(1165933386) 170} 171 172-- Iteration 5 -- 173array(9) { 174 ["sunrise"]=> 175 int(1165895237) 176 ["sunset"]=> 177 int(1165936713) 178 ["transit"]=> 179 int(1165915975) 180 ["civil_twilight_begin"]=> 181 int(1165893873) 182 ["civil_twilight_end"]=> 183 int(1165938077) 184 ["nautical_twilight_begin"]=> 185 int(1165892293) 186 ["nautical_twilight_end"]=> 187 int(1165939656) 188 ["astronomical_twilight_begin"]=> 189 int(1165890721) 190 ["astronomical_twilight_end"]=> 191 int(1165941229) 192} 193 194-- Iteration 6 -- 195array(9) { 196 ["sunrise"]=> 197 int(1165893058) 198 ["sunset"]=> 199 int(1165938891) 200 ["transit"]=> 201 int(1165915975) 202 ["civil_twilight_begin"]=> 203 int(1165891680) 204 ["civil_twilight_end"]=> 205 int(1165940269) 206 ["nautical_twilight_begin"]=> 207 int(1165890055) 208 ["nautical_twilight_end"]=> 209 int(1165941895) 210 ["astronomical_twilight_begin"]=> 211 int(1165888402) 212 ["astronomical_twilight_end"]=> 213 int(1165943548) 214} 215 216-- Iteration 7 -- 217array(9) { 218 ["sunrise"]=> 219 int(1165894152) 220 ["sunset"]=> 221 int(1165937798) 222 ["transit"]=> 223 int(1165915975) 224 ["civil_twilight_begin"]=> 225 int(1165892809) 226 ["civil_twilight_end"]=> 227 int(1165939141) 228 ["nautical_twilight_begin"]=> 229 int(1165891239) 230 ["nautical_twilight_end"]=> 231 int(1165940710) 232 ["astronomical_twilight_begin"]=> 233 int(1165889663) 234 ["astronomical_twilight_end"]=> 235 int(1165942287) 236} 237 238-- Iteration 8 -- 239array(9) { 240 ["sunrise"]=> 241 int(1165894152) 242 ["sunset"]=> 243 int(1165937798) 244 ["transit"]=> 245 int(1165915975) 246 ["civil_twilight_begin"]=> 247 int(1165892809) 248 ["civil_twilight_end"]=> 249 int(1165939141) 250 ["nautical_twilight_begin"]=> 251 int(1165891239) 252 ["nautical_twilight_end"]=> 253 int(1165940710) 254 ["astronomical_twilight_begin"]=> 255 int(1165889663) 256 ["astronomical_twilight_end"]=> 257 int(1165942287) 258} 259 260-- Iteration 9 -- 261array(9) { 262 ["sunrise"]=> 263 int(1165894203) 264 ["sunset"]=> 265 int(1165937747) 266 ["transit"]=> 267 int(1165915975) 268 ["civil_twilight_begin"]=> 269 int(1165892860) 270 ["civil_twilight_end"]=> 271 int(1165939090) 272 ["nautical_twilight_begin"]=> 273 int(1165891292) 274 ["nautical_twilight_end"]=> 275 int(1165940658) 276 ["astronomical_twilight_begin"]=> 277 int(1165889717) 278 ["astronomical_twilight_end"]=> 279 int(1165942233) 280} 281 282-- Iteration 10 -- 283array(9) { 284 ["sunrise"]=> 285 int(1165894152) 286 ["sunset"]=> 287 int(1165937798) 288 ["transit"]=> 289 int(1165915975) 290 ["civil_twilight_begin"]=> 291 int(1165892809) 292 ["civil_twilight_end"]=> 293 int(1165939141) 294 ["nautical_twilight_begin"]=> 295 int(1165891239) 296 ["nautical_twilight_end"]=> 297 int(1165940710) 298 ["astronomical_twilight_begin"]=> 299 int(1165889663) 300 ["astronomical_twilight_end"]=> 301 int(1165942287) 302} 303 304-- Iteration 11 -- 305array(9) { 306 ["sunrise"]=> 307 int(1165894152) 308 ["sunset"]=> 309 int(1165937798) 310 ["transit"]=> 311 int(1165915975) 312 ["civil_twilight_begin"]=> 313 int(1165892809) 314 ["civil_twilight_end"]=> 315 int(1165939141) 316 ["nautical_twilight_begin"]=> 317 int(1165891239) 318 ["nautical_twilight_end"]=> 319 int(1165940710) 320 ["astronomical_twilight_begin"]=> 321 int(1165889663) 322 ["astronomical_twilight_end"]=> 323 int(1165942287) 324} 325 326-- Iteration 12 -- 327array(9) { 328 ["sunrise"]=> 329 int(1165894254) 330 ["sunset"]=> 331 int(1165937695) 332 ["transit"]=> 333 int(1165915975) 334 ["civil_twilight_begin"]=> 335 int(1165892911) 336 ["civil_twilight_end"]=> 337 int(1165939038) 338 ["nautical_twilight_begin"]=> 339 int(1165891344) 340 ["nautical_twilight_end"]=> 341 int(1165940606) 342 ["astronomical_twilight_begin"]=> 343 int(1165889771) 344 ["astronomical_twilight_end"]=> 345 int(1165942179) 346} 347 348-- Iteration 13 -- 349array(9) { 350 ["sunrise"]=> 351 int(1165894152) 352 ["sunset"]=> 353 int(1165937798) 354 ["transit"]=> 355 int(1165915975) 356 ["civil_twilight_begin"]=> 357 int(1165892809) 358 ["civil_twilight_end"]=> 359 int(1165939141) 360 ["nautical_twilight_begin"]=> 361 int(1165891239) 362 ["nautical_twilight_end"]=> 363 int(1165940710) 364 ["astronomical_twilight_begin"]=> 365 int(1165889663) 366 ["astronomical_twilight_end"]=> 367 int(1165942287) 368} 369 370-- Iteration 14 -- 371array(9) { 372 ["sunrise"]=> 373 int(1165894254) 374 ["sunset"]=> 375 int(1165937695) 376 ["transit"]=> 377 int(1165915975) 378 ["civil_twilight_begin"]=> 379 int(1165892911) 380 ["civil_twilight_end"]=> 381 int(1165939038) 382 ["nautical_twilight_begin"]=> 383 int(1165891344) 384 ["nautical_twilight_end"]=> 385 int(1165940606) 386 ["astronomical_twilight_begin"]=> 387 int(1165889771) 388 ["astronomical_twilight_end"]=> 389 int(1165942179) 390} 391 392-- Iteration 15 -- 393array(9) { 394 ["sunrise"]=> 395 int(1165894152) 396 ["sunset"]=> 397 int(1165937798) 398 ["transit"]=> 399 int(1165915975) 400 ["civil_twilight_begin"]=> 401 int(1165892809) 402 ["civil_twilight_end"]=> 403 int(1165939141) 404 ["nautical_twilight_begin"]=> 405 int(1165891239) 406 ["nautical_twilight_end"]=> 407 int(1165940710) 408 ["astronomical_twilight_begin"]=> 409 int(1165889663) 410 ["astronomical_twilight_end"]=> 411 int(1165942287) 412} 413 414-- Iteration 16 -- 415 416Warning: date_sun_info() expects parameter 2 to be double, string given in %s on line %d 417bool(false) 418 419-- Iteration 17 -- 420 421Warning: date_sun_info() expects parameter 2 to be double, string given in %s on line %d 422bool(false) 423 424-- Iteration 18 -- 425 426Warning: date_sun_info() expects parameter 2 to be double, array given in %s on line %d 427bool(false) 428 429-- Iteration 19 -- 430 431Warning: date_sun_info() expects parameter 2 to be double, string given in %s on line %d 432bool(false) 433 434-- Iteration 20 -- 435 436Warning: date_sun_info() expects parameter 2 to be double, string given in %s on line %d 437bool(false) 438 439-- Iteration 21 -- 440 441Warning: date_sun_info() expects parameter 2 to be double, string given in %s on line %d 442bool(false) 443 444-- Iteration 22 -- 445array(9) { 446 ["sunrise"]=> 447 int(1165894152) 448 ["sunset"]=> 449 int(1165937798) 450 ["transit"]=> 451 int(1165915975) 452 ["civil_twilight_begin"]=> 453 int(1165892809) 454 ["civil_twilight_end"]=> 455 int(1165939141) 456 ["nautical_twilight_begin"]=> 457 int(1165891239) 458 ["nautical_twilight_end"]=> 459 int(1165940710) 460 ["astronomical_twilight_begin"]=> 461 int(1165889663) 462 ["astronomical_twilight_end"]=> 463 int(1165942287) 464} 465 466-- Iteration 23 -- 467array(9) { 468 ["sunrise"]=> 469 int(1165894152) 470 ["sunset"]=> 471 int(1165937798) 472 ["transit"]=> 473 int(1165915975) 474 ["civil_twilight_begin"]=> 475 int(1165892809) 476 ["civil_twilight_end"]=> 477 int(1165939141) 478 ["nautical_twilight_begin"]=> 479 int(1165891239) 480 ["nautical_twilight_end"]=> 481 int(1165940710) 482 ["astronomical_twilight_begin"]=> 483 int(1165889663) 484 ["astronomical_twilight_end"]=> 485 int(1165942287) 486} 487 488-- Iteration 24 -- 489 490Warning: date_sun_info() expects parameter 2 to be double, resource given in %s on line %d 491bool(false) 492===Done=== 493