1--TEST-- 2Test timezone_offset_get() function : error conditions 3--FILE-- 4<?php 5//Set the default time zone 6date_default_timezone_set("GMT"); 7$tz = timezone_open("Europe/London"); 8$date = date_create("GMT"); 9 10echo "*** Testing timezone_offset_get() : error conditions ***\n"; 11 12echo "\n-- Testing timezone_offset_get() function with an invalid values for \$object argument --\n"; 13$invalid_obj = new stdClass(); 14try { 15 var_dump( timezone_offset_get($invalid_obj, $date) ); 16} catch (Error $ex) { 17 var_dump($ex->getMessage()); 18 echo "\n"; 19} 20$invalid_obj = 10; 21try { 22 var_dump( timezone_offset_get($invalid_obj, $date) ); 23} catch (Error $ex) { 24 var_dump($ex->getMessage()); 25 echo "\n"; 26} 27$invalid_obj = null; 28try { 29 var_dump( timezone_offset_get($invalid_obj, $date) ); 30} catch (Error $ex) { 31 var_dump($ex->getMessage()); 32 echo "\n"; 33} 34 35echo "\n-- Testing timezone_offset_get() function with an invalid values for \$datetime argument --\n"; 36$invalid_obj = new stdClass(); 37try { 38 var_dump( timezone_offset_get($tz, $invalid_obj) ); 39} catch (Error $ex) { 40 var_dump($ex->getMessage()); 41 echo "\n"; 42} 43$invalid_obj = 10; 44try { 45 var_dump( timezone_offset_get($tz, $invalid_obj) ); 46} catch (Error $ex) { 47 var_dump($ex->getMessage()); 48 echo "\n"; 49} 50$invalid_obj = null; 51try { 52 var_dump( timezone_offset_get($tz, $invalid_obj) ); 53} catch (Error $ex) { 54 var_dump($ex->getMessage()); 55 echo "\n"; 56} 57?> 58--EXPECT-- 59*** Testing timezone_offset_get() : error conditions *** 60 61-- Testing timezone_offset_get() function with an invalid values for $object argument -- 62string(89) "timezone_offset_get(): Argument #1 ($object) must be of type DateTimeZone, stdClass given" 63 64string(84) "timezone_offset_get(): Argument #1 ($object) must be of type DateTimeZone, int given" 65 66string(85) "timezone_offset_get(): Argument #1 ($object) must be of type DateTimeZone, null given" 67 68 69-- Testing timezone_offset_get() function with an invalid values for $datetime argument -- 70string(96) "timezone_offset_get(): Argument #2 ($datetime) must be of type DateTimeInterface, stdClass given" 71 72string(91) "timezone_offset_get(): Argument #2 ($datetime) must be of type DateTimeInterface, int given" 73 74string(92) "timezone_offset_get(): Argument #2 ($datetime) must be of type DateTimeInterface, null given" 75