1--TEST-- 2Test timezone_offset_get() function : error conditions 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 11//Set the default time zone 12date_default_timezone_set("GMT"); 13$tz = timezone_open("Europe/London"); 14$date = date_create("GMT"); 15 16echo "*** Testing timezone_offset_get() : error conditions ***\n"; 17 18echo "\n-- Testing timezone_offset_get() function with zero arguments --\n"; 19var_dump( timezone_offset_get() ); 20 21echo "\n-- Testing timezone_offset_get() function with less than expected no. of arguments --\n"; 22var_dump( timezone_offset_get($tz) ); 23 24echo "\n-- Testing timezone_offset_get() function with more than expected no. of arguments --\n"; 25$extra_arg = 99; 26var_dump( timezone_offset_get($tz, $date, $extra_arg) ); 27 28echo "\n-- Testing timezone_offset_get() function with an invalid values for \$object argument --\n"; 29$invalid_obj = new stdClass(); 30var_dump( timezone_offset_get($invalid_obj, $date) ); 31$invalid_obj = 10; 32var_dump( timezone_offset_get($invalid_obj, $date) ); 33$invalid_obj = null; 34var_dump( timezone_offset_get($invalid_obj, $date) ); 35 36echo "\n-- Testing timezone_offset_get() function with an invalid values for \$datetime argument --\n"; 37$invalid_obj = new stdClass(); 38var_dump( timezone_offset_get($tz, $invalid_obj) ); 39$invalid_obj = 10; 40var_dump( timezone_offset_get($tz, $invalid_obj) ); 41$invalid_obj = null; 42var_dump( timezone_offset_get($tz, $invalid_obj) ); 43?> 44===DONE=== 45--EXPECTF-- 46*** Testing timezone_offset_get() : error conditions *** 47 48-- Testing timezone_offset_get() function with zero arguments -- 49 50Warning: timezone_offset_get() expects exactly 2 parameters, 0 given in %s on line %d 51bool(false) 52 53-- Testing timezone_offset_get() function with less than expected no. of arguments -- 54 55Warning: timezone_offset_get() expects exactly 2 parameters, 1 given in %s on line %d 56bool(false) 57 58-- Testing timezone_offset_get() function with more than expected no. of arguments -- 59 60Warning: timezone_offset_get() expects exactly 2 parameters, 3 given in %s on line %d 61bool(false) 62 63-- Testing timezone_offset_get() function with an invalid values for $object argument -- 64 65Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d 66bool(false) 67 68Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d 69bool(false) 70 71Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d 72bool(false) 73 74-- Testing timezone_offset_get() function with an invalid values for $datetime argument -- 75 76Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d 77bool(false) 78 79Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d 80bool(false) 81 82Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d 83bool(false) 84===DONE=== 85