1--TEST-- 2Test timezone_transitions_get() function : usage variation - Passing unexpected values to first argument $timestamp_begin. 3--FILE-- 4<?php 5/* Prototype : array timezone_transitions_get ( DateTimeZone $object, [ int $timestamp_begin [, int $timestamp_end ]] ) 6 * Description: Returns all transitions for the timezone 7 * Source code: ext/date/php_date.c 8 * Alias to functions: DateTimeZone::getTransitions() 9 */ 10 11echo "*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument \$timestamp_begin ***\n"; 12 13//Set the default time zone 14date_default_timezone_set("Europe/London"); 15 16//get an unset variable 17$unset_var = 10; 18unset ($unset_var); 19 20// define some classes 21class classWithToString 22{ 23 public function __toString() { 24 return "Class A object"; 25 } 26} 27 28class classWithoutToString 29{ 30} 31 32// heredoc string 33$heredoc = <<<EOT 34hello world 35EOT; 36 37// add arrays 38$index_array = array (1, 2, 3); 39$assoc_array = array ('one' => 1, 'two' => 2); 40 41// resource 42$file_handle = fopen(__FILE__, 'r'); 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 // float data 54 'float 10.5' => 10.5, 55 'float -10.5' => -10.5, 56 'float .5' => .5, 57 58 // array data 59 'empty array' => array(), 60 'int indexed array' => $index_array, 61 'associative array' => $assoc_array, 62 'nested arrays' => array('foo', $index_array, $assoc_array), 63 64 // null data 65 'uppercase NULL' => NULL, 66 'lowercase null' => null, 67 68 // boolean data 69 'lowercase true' => true, 70 'lowercase false' =>false, 71 'uppercase TRUE' =>TRUE, 72 'uppercase FALSE' =>FALSE, 73 74 // empty data 75 'empty string DQ' => "", 76 'empty string SQ' => '', 77 78 // string data 79 'string DQ' => "string", 80 'string SQ' => 'string', 81 'mixed case string' => "sTrInG", 82 'heredoc' => $heredoc, 83 84 // object data 85 'instance of classWithToString' => new classWithToString(), 86 'instance of classWithoutToString' => new classWithoutToString(), 87 88 // undefined data 89 'undefined var' => @$undefined_var, 90 91 // unset data 92 'unset var' => @$unset_var, 93 94 // resource 95 'resource' => $file_handle 96); 97 98$tz = timezone_open("Europe/London"); 99$timestamp_end = mktime(0, 0, 0, 1, 1, 1975); 100 101foreach($inputs as $variation =>$timestamp_begin) { 102 echo "\n-- $variation --\n"; 103 $tran = timezone_transitions_get($tz, $timestamp_begin, $timestamp_end); 104 var_dump( gettype($tran) ); 105 var_dump( count($tran) ); 106}; 107 108// closing the resource 109fclose( $file_handle ); 110 111?> 112===DONE=== 113--EXPECTF-- 114*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument $timestamp_begin *** 115 116-- int 0 -- 117string(5) "array" 118int(8) 119 120-- int 1 -- 121string(5) "array" 122int(8) 123 124-- int 12345 -- 125string(5) "array" 126int(8) 127 128-- int -12345 -- 129string(5) "array" 130int(8) 131 132-- float 10.5 -- 133string(5) "array" 134int(8) 135 136-- float -10.5 -- 137string(5) "array" 138int(8) 139 140-- float .5 -- 141string(5) "array" 142int(8) 143 144-- empty array -- 145 146Warning: timezone_transitions_get() expects parameter 2 to be integer, array given in %s on line %d 147string(7) "boolean" 148int(1) 149 150-- int indexed array -- 151 152Warning: timezone_transitions_get() expects parameter 2 to be integer, array given in %s on line %d 153string(7) "boolean" 154int(1) 155 156-- associative array -- 157 158Warning: timezone_transitions_get() expects parameter 2 to be integer, array given in %s on line %d 159string(7) "boolean" 160int(1) 161 162-- nested arrays -- 163 164Warning: timezone_transitions_get() expects parameter 2 to be integer, array given in %s on line %d 165string(7) "boolean" 166int(1) 167 168-- uppercase NULL -- 169string(5) "array" 170int(8) 171 172-- lowercase null -- 173string(5) "array" 174int(8) 175 176-- lowercase true -- 177string(5) "array" 178int(8) 179 180-- lowercase false -- 181string(5) "array" 182int(8) 183 184-- uppercase TRUE -- 185string(5) "array" 186int(8) 187 188-- uppercase FALSE -- 189string(5) "array" 190int(8) 191 192-- empty string DQ -- 193 194Warning: timezone_transitions_get() expects parameter 2 to be integer, string given in %s on line %d 195string(7) "boolean" 196int(1) 197 198-- empty string SQ -- 199 200Warning: timezone_transitions_get() expects parameter 2 to be integer, string given in %s on line %d 201string(7) "boolean" 202int(1) 203 204-- string DQ -- 205 206Warning: timezone_transitions_get() expects parameter 2 to be integer, string given in %s on line %d 207string(7) "boolean" 208int(1) 209 210-- string SQ -- 211 212Warning: timezone_transitions_get() expects parameter 2 to be integer, string given in %s on line %d 213string(7) "boolean" 214int(1) 215 216-- mixed case string -- 217 218Warning: timezone_transitions_get() expects parameter 2 to be integer, string given in %s on line %d 219string(7) "boolean" 220int(1) 221 222-- heredoc -- 223 224Warning: timezone_transitions_get() expects parameter 2 to be integer, string given in %s on line %d 225string(7) "boolean" 226int(1) 227 228-- instance of classWithToString -- 229 230Warning: timezone_transitions_get() expects parameter 2 to be integer, object given in %s on line %d 231string(7) "boolean" 232int(1) 233 234-- instance of classWithoutToString -- 235 236Warning: timezone_transitions_get() expects parameter 2 to be integer, object given in %s on line %d 237string(7) "boolean" 238int(1) 239 240-- undefined var -- 241string(5) "array" 242int(8) 243 244-- unset var -- 245string(5) "array" 246int(8) 247 248-- resource -- 249 250Warning: timezone_transitions_get() expects parameter 2 to be integer, resource given in %s on line %d 251string(7) "boolean" 252int(1) 253===DONE=== 254