1--TEST-- 2Test date_sunrise() function : usage variation - Passing unexpected values to third argument latitude. 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 function arguments not being substituted (if any) 13date_default_timezone_set("Asia/Calcutta"); 14$time = mktime(8, 8, 8, 8, 8, 2008); 15$longitude = -9; 16$zenith = 90; 17$gmt_offset = -5.5; 18 19//get an unset variable 20$unset_var = 10; 21unset ($unset_var); 22 23// define some classes 24class classWithToString 25{ 26 public function __toString() { 27 return "Class A object"; 28 } 29} 30 31class classWithoutToString 32{ 33} 34 35// heredoc string 36$heredoc = <<<EOT 37hello world 38EOT; 39 40// add arrays 41$index_array = array (1, 2, 3); 42$assoc_array = array ('one' => 1, 'two' => 2); 43 44//array of values to iterate over 45$inputs = array( 46 47 // int data 48 'int 0' => 0, 49 'int 1' => 1, 50 'int 12345' => 12345, 51 'int -12345' => -12345, 52 53 // array data 54 'empty array' => array(), 55 'int indexed array' => $index_array, 56 'associative array' => $assoc_array, 57 'nested arrays' => array('foo', $index_array, $assoc_array), 58 59 // null data 60 'uppercase NULL' => NULL, 61 'lowercase null' => null, 62 63 // boolean data 64 'lowercase true' => true, 65 'lowercase false' =>false, 66 'uppercase TRUE' =>TRUE, 67 'uppercase FALSE' =>FALSE, 68 69 // empty data 70 'empty string DQ' => "", 71 'empty string SQ' => '', 72 73 // string data 74 'string DQ' => "string", 75 'string SQ' => 'string', 76 'mixed case string' => "sTrInG", 77 'heredoc' => $heredoc, 78 79 // object data 80 'instance of classWithToString' => new classWithToString(), 81 'instance of classWithoutToString' => new classWithoutToString(), 82 83 // undefined data 84 'undefined var' => @$undefined_var, 85 86 // unset data 87 'unset var' => @$unset_var, 88); 89 90// loop through each element of the array for latitude 91 92foreach($inputs as $key =>$value) { 93 echo "\n--$key--\n"; 94 var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $value, $longitude, $zenith, $gmt_offset) ); 95 var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, $value, $longitude, $zenith, $gmt_offset) ); 96 var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $value, $longitude, $zenith, $gmt_offset) ); 97}; 98?> 99===DONE=== 100--EXPECTF-- 101*** Testing date_sunrise() : usage variation *** 102 103--int 0-- 104string(5) "01:10" 105float(1.174%d) 106int(1218177627) 107 108--int 1-- 109string(5) "01:09" 110float(1.155%d) 111int(1218177558) 112 113--int 12345-- 114bool(false) 115bool(false) 116bool(false) 117 118--int -12345-- 119bool(false) 120bool(false) 121bool(false) 122 123--empty array-- 124 125Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d 126bool(false) 127 128Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d 129bool(false) 130 131Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d 132bool(false) 133 134--int indexed array-- 135 136Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d 137bool(false) 138 139Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d 140bool(false) 141 142Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d 143bool(false) 144 145--associative array-- 146 147Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d 148bool(false) 149 150Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d 151bool(false) 152 153Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d 154bool(false) 155 156--nested arrays-- 157 158Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d 159bool(false) 160 161Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d 162bool(false) 163 164Warning: date_sunrise() expects parameter 3 to be double, array given in %s on line %d 165bool(false) 166 167--uppercase NULL-- 168string(5) "01:10" 169float(1.174%d) 170int(1218177627) 171 172--lowercase null-- 173string(5) "01:10" 174float(1.174%d) 175int(1218177627) 176 177--lowercase true-- 178string(5) "01:09" 179float(1.155%d) 180int(1218177558) 181 182--lowercase false-- 183string(5) "01:10" 184float(1.174%d) 185int(1218177627) 186 187--uppercase TRUE-- 188string(5) "01:09" 189float(1.155%d) 190int(1218177558) 191 192--uppercase FALSE-- 193string(5) "01:10" 194float(1.174%d) 195int(1218177627) 196 197--empty string DQ-- 198 199Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 200bool(false) 201 202Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 203bool(false) 204 205Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 206bool(false) 207 208--empty string SQ-- 209 210Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 211bool(false) 212 213Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 214bool(false) 215 216Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 217bool(false) 218 219--string DQ-- 220 221Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 222bool(false) 223 224Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 225bool(false) 226 227Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 228bool(false) 229 230--string SQ-- 231 232Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 233bool(false) 234 235Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 236bool(false) 237 238Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 239bool(false) 240 241--mixed case string-- 242 243Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 244bool(false) 245 246Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 247bool(false) 248 249Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 250bool(false) 251 252--heredoc-- 253 254Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 255bool(false) 256 257Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 258bool(false) 259 260Warning: date_sunrise() expects parameter 3 to be double, string given in %s on line %d 261bool(false) 262 263--instance of classWithToString-- 264 265Warning: date_sunrise() expects parameter 3 to be double, object given in %s on line %d 266bool(false) 267 268Warning: date_sunrise() expects parameter 3 to be double, object given in %s on line %d 269bool(false) 270 271Warning: date_sunrise() expects parameter 3 to be double, object given in %s on line %d 272bool(false) 273 274--instance of classWithoutToString-- 275 276Warning: date_sunrise() expects parameter 3 to be double, object given in %s on line %d 277bool(false) 278 279Warning: date_sunrise() expects parameter 3 to be double, object given in %s on line %d 280bool(false) 281 282Warning: date_sunrise() expects parameter 3 to be double, object given in %s on line %d 283bool(false) 284 285--undefined var-- 286string(5) "01:10" 287float(1.174%d) 288int(1218177627) 289 290--unset var-- 291string(5) "01:10" 292float(1.174%d) 293int(1218177627) 294===DONE=== 295