Annotation of embedaddon/php/ext/date/tests/date_timezone_set_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test date_timezone_set() function : usage variation - Passing unexpected values to first argument $object.
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : DateTime date_timezone_set ( DateTime $object , DateTimeZone $timezone )
! 6: * Description: Sets the time zone for the DateTime object
! 7: * Source code: ext/date/php_date.c
! 8: * Alias to functions: DateTime::setTimezone
! 9: */
! 10:
! 11: echo "*** Testing date_timezone_set() : usage variation - unexpected values to first argument \$object***\n";
! 12:
! 13: //Set the default time zone
! 14: date_default_timezone_set("Europe/London");
! 15:
! 16: //get an unset variable
! 17: $unset_var = 10;
! 18: unset ($unset_var);
! 19:
! 20: // define some classes
! 21: class classWithToString
! 22: {
! 23: public function __toString() {
! 24: return "Class A object";
! 25: }
! 26: }
! 27:
! 28: class classWithoutToString
! 29: {
! 30: }
! 31:
! 32: // heredoc string
! 33: $heredoc = <<<EOT
! 34: hello world
! 35: EOT;
! 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: $timezone = timezone_open("America/Los_Angeles");
! 99:
! 100: foreach($inputs as $variation =>$object) {
! 101: echo "\n-- $variation --\n";
! 102: var_dump( date_timezone_set($object, $timezone) );
! 103: };
! 104:
! 105:
! 106: // closing the resource
! 107: fclose( $file_handle );
! 108:
! 109: ?>
! 110: ===DONE===
! 111: --EXPECTF--
! 112: *** Testing date_timezone_set() : usage variation - unexpected values to first argument $object***
! 113:
! 114: -- int 0 --
! 115:
! 116: Warning: date_timezone_set() expects parameter 1 to be DateTime, integer given in %s on line %d
! 117: bool(false)
! 118:
! 119: -- int 1 --
! 120:
! 121: Warning: date_timezone_set() expects parameter 1 to be DateTime, integer given in %s on line %d
! 122: bool(false)
! 123:
! 124: -- int 12345 --
! 125:
! 126: Warning: date_timezone_set() expects parameter 1 to be DateTime, integer given in %s on line %d
! 127: bool(false)
! 128:
! 129: -- int -12345 --
! 130:
! 131: Warning: date_timezone_set() expects parameter 1 to be DateTime, integer given in %s on line %d
! 132: bool(false)
! 133:
! 134: -- float 10.5 --
! 135:
! 136: Warning: date_timezone_set() expects parameter 1 to be DateTime, double given in %s on line %d
! 137: bool(false)
! 138:
! 139: -- float -10.5 --
! 140:
! 141: Warning: date_timezone_set() expects parameter 1 to be DateTime, double given in %s on line %d
! 142: bool(false)
! 143:
! 144: -- float .5 --
! 145:
! 146: Warning: date_timezone_set() expects parameter 1 to be DateTime, double given in %s on line %d
! 147: bool(false)
! 148:
! 149: -- empty array --
! 150:
! 151: Warning: date_timezone_set() expects parameter 1 to be DateTime, array given in %s on line %d
! 152: bool(false)
! 153:
! 154: -- int indexed array --
! 155:
! 156: Warning: date_timezone_set() expects parameter 1 to be DateTime, array given in %s on line %d
! 157: bool(false)
! 158:
! 159: -- associative array --
! 160:
! 161: Warning: date_timezone_set() expects parameter 1 to be DateTime, array given in %s on line %d
! 162: bool(false)
! 163:
! 164: -- nested arrays --
! 165:
! 166: Warning: date_timezone_set() expects parameter 1 to be DateTime, array given in %s on line %d
! 167: bool(false)
! 168:
! 169: -- uppercase NULL --
! 170:
! 171: Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d
! 172: bool(false)
! 173:
! 174: -- lowercase null --
! 175:
! 176: Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d
! 177: bool(false)
! 178:
! 179: -- lowercase true --
! 180:
! 181: Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in %s on line %d
! 182: bool(false)
! 183:
! 184: -- lowercase false --
! 185:
! 186: Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in %s on line %d
! 187: bool(false)
! 188:
! 189: -- uppercase TRUE --
! 190:
! 191: Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in %s on line %d
! 192: bool(false)
! 193:
! 194: -- uppercase FALSE --
! 195:
! 196: Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in %s on line %d
! 197: bool(false)
! 198:
! 199: -- empty string DQ --
! 200:
! 201: Warning: date_timezone_set() expects parameter 1 to be DateTime, string given in %s on line %d
! 202: bool(false)
! 203:
! 204: -- empty string SQ --
! 205:
! 206: Warning: date_timezone_set() expects parameter 1 to be DateTime, string given in %s on line %d
! 207: bool(false)
! 208:
! 209: -- string DQ --
! 210:
! 211: Warning: date_timezone_set() expects parameter 1 to be DateTime, string given in %s on line %d
! 212: bool(false)
! 213:
! 214: -- string SQ --
! 215:
! 216: Warning: date_timezone_set() expects parameter 1 to be DateTime, string given in %s on line %d
! 217: bool(false)
! 218:
! 219: -- mixed case string --
! 220:
! 221: Warning: date_timezone_set() expects parameter 1 to be DateTime, string given in %s on line %d
! 222: bool(false)
! 223:
! 224: -- heredoc --
! 225:
! 226: Warning: date_timezone_set() expects parameter 1 to be DateTime, string given in %s on line %d
! 227: bool(false)
! 228:
! 229: -- instance of classWithToString --
! 230:
! 231: Warning: date_timezone_set() expects parameter 1 to be DateTime, object given in %s on line %d
! 232: bool(false)
! 233:
! 234: -- instance of classWithoutToString --
! 235:
! 236: Warning: date_timezone_set() expects parameter 1 to be DateTime, object given in %s on line %d
! 237: bool(false)
! 238:
! 239: -- undefined var --
! 240:
! 241: Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d
! 242: bool(false)
! 243:
! 244: -- unset var --
! 245:
! 246: Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d
! 247: bool(false)
! 248:
! 249: -- resource --
! 250:
! 251: Warning: date_timezone_set() expects parameter 1 to be DateTime, resource given in %s on line %d
! 252: bool(false)
! 253: ===DONE===
! 254:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>