1--TEST-- 2Test timezone_offset_get() function : usage variation - Passing unexpected values to second argument $datetime. 3--FILE-- 4<?php 5/* Prototype : int timezone_offset_get ( DateTimeZone $object , DateTime $datetime ) 6 * Description: Returns the timezone offset from GMT 7 * Source code: ext/date/php_date.c 8 * Alias to functions: DateTimeZone::getOffset() 9 */ 10 11echo "*** Testing timezone_offset_get() : usage variation - unexpected values to second argument \$datetime***\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$object = new DateTimezone("Europe/London"); 99 100foreach($inputs as $variation =>$datetime) { 101 echo "\n-- $variation --\n"; 102 var_dump( timezone_offset_get($object, $datetime) ); 103}; 104 105// closing the resource 106fclose( $file_handle ); 107 108?> 109===DONE=== 110--EXPECTF-- 111*** Testing timezone_offset_get() : usage variation - unexpected values to second argument $datetime*** 112 113-- int 0 -- 114 115Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d 116bool(false) 117 118-- int 1 -- 119 120Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d 121bool(false) 122 123-- int 12345 -- 124 125Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d 126bool(false) 127 128-- int -12345 -- 129 130Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d 131bool(false) 132 133-- float 10.5 -- 134 135Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d 136bool(false) 137 138-- float -10.5 -- 139 140Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d 141bool(false) 142 143-- float .5 -- 144 145Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d 146bool(false) 147 148-- empty array -- 149 150Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d 151bool(false) 152 153-- int indexed array -- 154 155Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d 156bool(false) 157 158-- associative array -- 159 160Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d 161bool(false) 162 163-- nested arrays -- 164 165Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d 166bool(false) 167 168-- uppercase NULL -- 169 170Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d 171bool(false) 172 173-- lowercase null -- 174 175Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d 176bool(false) 177 178-- lowercase true -- 179 180Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d 181bool(false) 182 183-- lowercase false -- 184 185Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d 186bool(false) 187 188-- uppercase TRUE -- 189 190Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d 191bool(false) 192 193-- uppercase FALSE -- 194 195Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d 196bool(false) 197 198-- empty string DQ -- 199 200Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d 201bool(false) 202 203-- empty string SQ -- 204 205Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d 206bool(false) 207 208-- string DQ -- 209 210Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d 211bool(false) 212 213-- string SQ -- 214 215Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d 216bool(false) 217 218-- mixed case string -- 219 220Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d 221bool(false) 222 223-- heredoc -- 224 225Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d 226bool(false) 227 228-- instance of classWithToString -- 229 230Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d 231bool(false) 232 233-- instance of classWithoutToString -- 234 235Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d 236bool(false) 237 238-- undefined var -- 239 240Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d 241bool(false) 242 243-- unset var -- 244 245Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d 246bool(false) 247 248-- resource -- 249 250Warning: timezone_offset_get() expects parameter 2 to be DateTime, resource given in %s on line %d 251bool(false) 252===DONE=== 253