Annotation of embedaddon/php/ext/date/tests/DateTime_setDate_variation2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test DateTime::setDate() function : usage variation - Passing unexpected values to second argument $month.
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : public DateTime DateTime::setDate ( int $year , int $month , int $day )
! 6: * Description: Resets the current date of the DateTime object to a different date.
! 7: * Source code: ext/date/php_date.c
! 8: * Alias to functions: date_date_set
! 9: */
! 10:
! 11: echo "*** Testing DateTime::setDate() : usage variation - unexpected values to second argument \$month***\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: $object = new DateTime("2009-02-27 08:34:10");
! 99: $day = 2;
! 100: $year = 1963;
! 101:
! 102: foreach($inputs as $variation =>$month) {
! 103: echo "\n-- $variation --\n";
! 104: var_dump( $object->setDate($year, $month, $day) );
! 105: };
! 106:
! 107: // closing the resource
! 108: fclose( $file_handle );
! 109:
! 110: ?>
! 111: ===DONE===
! 112: --EXPECTF--
! 113: *** Testing DateTime::setDate() : usage variation - unexpected values to second argument $month***
! 114:
! 115: -- int 0 --
! 116: object(DateTime)#%d (3) {
! 117: ["date"]=>
! 118: string(19) "1962-12-02 08:34:10"
! 119: ["timezone_type"]=>
! 120: int(3)
! 121: ["timezone"]=>
! 122: string(13) "Europe/London"
! 123: }
! 124:
! 125: -- int 1 --
! 126: object(DateTime)#%d (3) {
! 127: ["date"]=>
! 128: string(19) "1963-01-02 08:34:10"
! 129: ["timezone_type"]=>
! 130: int(3)
! 131: ["timezone"]=>
! 132: string(13) "Europe/London"
! 133: }
! 134:
! 135: -- int 12345 --
! 136: object(DateTime)#%d (3) {
! 137: ["date"]=>
! 138: string(19) "2991-09-02 08:34:10"
! 139: ["timezone_type"]=>
! 140: int(3)
! 141: ["timezone"]=>
! 142: string(13) "Europe/London"
! 143: }
! 144:
! 145: -- int -12345 --
! 146: object(DateTime)#%d (3) {
! 147: ["date"]=>
! 148: string(19) "0934-03-02 08:34:10"
! 149: ["timezone_type"]=>
! 150: int(3)
! 151: ["timezone"]=>
! 152: string(13) "Europe/London"
! 153: }
! 154:
! 155: -- float 10.5 --
! 156: object(DateTime)#%d (3) {
! 157: ["date"]=>
! 158: string(19) "1963-10-02 08:34:10"
! 159: ["timezone_type"]=>
! 160: int(3)
! 161: ["timezone"]=>
! 162: string(13) "Europe/London"
! 163: }
! 164:
! 165: -- float -10.5 --
! 166: object(DateTime)#%d (3) {
! 167: ["date"]=>
! 168: string(19) "1962-02-02 08:34:10"
! 169: ["timezone_type"]=>
! 170: int(3)
! 171: ["timezone"]=>
! 172: string(13) "Europe/London"
! 173: }
! 174:
! 175: -- float .5 --
! 176: object(DateTime)#%d (3) {
! 177: ["date"]=>
! 178: string(19) "1962-12-02 08:34:10"
! 179: ["timezone_type"]=>
! 180: int(3)
! 181: ["timezone"]=>
! 182: string(13) "Europe/London"
! 183: }
! 184:
! 185: -- empty array --
! 186:
! 187: Warning: DateTime::setDate() expects parameter 2 to be long, array given in %s on line %d
! 188: bool(false)
! 189:
! 190: -- int indexed array --
! 191:
! 192: Warning: DateTime::setDate() expects parameter 2 to be long, array given in %s on line %d
! 193: bool(false)
! 194:
! 195: -- associative array --
! 196:
! 197: Warning: DateTime::setDate() expects parameter 2 to be long, array given in %s on line %d
! 198: bool(false)
! 199:
! 200: -- nested arrays --
! 201:
! 202: Warning: DateTime::setDate() expects parameter 2 to be long, array given in %s on line %d
! 203: bool(false)
! 204:
! 205: -- uppercase NULL --
! 206: object(DateTime)#%d (3) {
! 207: ["date"]=>
! 208: string(19) "1962-12-02 08:34:10"
! 209: ["timezone_type"]=>
! 210: int(3)
! 211: ["timezone"]=>
! 212: string(13) "Europe/London"
! 213: }
! 214:
! 215: -- lowercase null --
! 216: object(DateTime)#%d (3) {
! 217: ["date"]=>
! 218: string(19) "1962-12-02 08:34:10"
! 219: ["timezone_type"]=>
! 220: int(3)
! 221: ["timezone"]=>
! 222: string(13) "Europe/London"
! 223: }
! 224:
! 225: -- lowercase true --
! 226: object(DateTime)#%d (3) {
! 227: ["date"]=>
! 228: string(19) "1963-01-02 08:34:10"
! 229: ["timezone_type"]=>
! 230: int(3)
! 231: ["timezone"]=>
! 232: string(13) "Europe/London"
! 233: }
! 234:
! 235: -- lowercase false --
! 236: object(DateTime)#%d (3) {
! 237: ["date"]=>
! 238: string(19) "1962-12-02 08:34:10"
! 239: ["timezone_type"]=>
! 240: int(3)
! 241: ["timezone"]=>
! 242: string(13) "Europe/London"
! 243: }
! 244:
! 245: -- uppercase TRUE --
! 246: object(DateTime)#%d (3) {
! 247: ["date"]=>
! 248: string(19) "1963-01-02 08:34:10"
! 249: ["timezone_type"]=>
! 250: int(3)
! 251: ["timezone"]=>
! 252: string(13) "Europe/London"
! 253: }
! 254:
! 255: -- uppercase FALSE --
! 256: object(DateTime)#%d (3) {
! 257: ["date"]=>
! 258: string(19) "1962-12-02 08:34:10"
! 259: ["timezone_type"]=>
! 260: int(3)
! 261: ["timezone"]=>
! 262: string(13) "Europe/London"
! 263: }
! 264:
! 265: -- empty string DQ --
! 266:
! 267: Warning: DateTime::setDate() expects parameter 2 to be long, string given in %s on line %d
! 268: bool(false)
! 269:
! 270: -- empty string SQ --
! 271:
! 272: Warning: DateTime::setDate() expects parameter 2 to be long, string given in %s on line %d
! 273: bool(false)
! 274:
! 275: -- string DQ --
! 276:
! 277: Warning: DateTime::setDate() expects parameter 2 to be long, string given in %s on line %d
! 278: bool(false)
! 279:
! 280: -- string SQ --
! 281:
! 282: Warning: DateTime::setDate() expects parameter 2 to be long, string given in %s on line %d
! 283: bool(false)
! 284:
! 285: -- mixed case string --
! 286:
! 287: Warning: DateTime::setDate() expects parameter 2 to be long, string given in %s on line %d
! 288: bool(false)
! 289:
! 290: -- heredoc --
! 291:
! 292: Warning: DateTime::setDate() expects parameter 2 to be long, string given in %s on line %d
! 293: bool(false)
! 294:
! 295: -- instance of classWithToString --
! 296:
! 297: Warning: DateTime::setDate() expects parameter 2 to be long, object given in %s on line %d
! 298: bool(false)
! 299:
! 300: -- instance of classWithoutToString --
! 301:
! 302: Warning: DateTime::setDate() expects parameter 2 to be long, object given in %s on line %d
! 303: bool(false)
! 304:
! 305: -- undefined var --
! 306: object(DateTime)#%d (3) {
! 307: ["date"]=>
! 308: string(19) "1962-12-02 08:34:10"
! 309: ["timezone_type"]=>
! 310: int(3)
! 311: ["timezone"]=>
! 312: string(13) "Europe/London"
! 313: }
! 314:
! 315: -- unset var --
! 316: object(DateTime)#%d (3) {
! 317: ["date"]=>
! 318: string(19) "1962-12-02 08:34:10"
! 319: ["timezone_type"]=>
! 320: int(3)
! 321: ["timezone"]=>
! 322: string(13) "Europe/London"
! 323: }
! 324:
! 325: -- resource --
! 326:
! 327: Warning: DateTime::setDate() expects parameter 2 to be long, resource given in %s on line %d
! 328: bool(false)
! 329: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>