Annotation of embedaddon/php/ext/date/tests/DateTime_modify_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test DateTime::modify() function : usage variation - Passing unexpected values to first argument $modify.
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : public DateTime DateTime::modify ( string $modify )
! 6: * Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime().
! 7: * Source code: ext/date/php_date.c
! 8: * Alias to functions: public date_modify()
! 9: */
! 10:
! 11: echo "*** Testing DateTime::modify() : usage variation - unexpected values to first argument \$modify***\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-01-31 14:28:41");
! 99:
! 100: foreach($inputs as $variation =>$format) {
! 101: echo "\n-- $variation --\n";
! 102: var_dump( $object->modify($format) );
! 103: };
! 104:
! 105: // closing the resource
! 106: fclose( $file_handle );
! 107:
! 108: ?>
! 109: ===DONE===
! 110: --EXPECTF--
! 111: *** Testing DateTime::modify() : usage variation - unexpected values to first argument $modify***
! 112:
! 113: -- int 0 --
! 114:
! 115: Warning: DateTime::modify(): Failed to parse time string (0) at position 0 (0): Unexpected character in %sDateTime_modify_variation1.php on line 99
! 116: bool(false)
! 117:
! 118: -- int 1 --
! 119:
! 120: Warning: DateTime::modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in %sDateTime_modify_variation1.php on line 99
! 121: bool(false)
! 122:
! 123: -- int 12345 --
! 124:
! 125: Warning: DateTime::modify(): Failed to parse time string (12345) at position 4 (5): Unexpected character in %sDateTime_modify_variation1.php on line 99
! 126: bool(false)
! 127:
! 128: -- int -12345 --
! 129:
! 130: Warning: DateTime::modify(): Failed to parse time string (-12345) at position 5 (5): Unexpected character in %sDateTime_modify_variation1.php on line 99
! 131: bool(false)
! 132:
! 133: -- float 10.5 --
! 134: object(DateTime)#3 (3) {
! 135: ["date"]=>
! 136: string(19) "2009-01-31 10:05:00"
! 137: ["timezone_type"]=>
! 138: int(3)
! 139: ["timezone"]=>
! 140: string(13) "Europe/London"
! 141: }
! 142:
! 143: -- float -10.5 --
! 144:
! 145: Warning: DateTime::modify(): Failed to parse time string (-10.5) at position 4 (5): Unexpected character in %sDateTime_modify_variation1.php on line 99
! 146: bool(false)
! 147:
! 148: -- float .5 --
! 149: object(DateTime)#3 (3) {
! 150: ["date"]=>
! 151: string(19) "2009-01-31 00:05:00"
! 152: ["timezone_type"]=>
! 153: int(3)
! 154: ["timezone"]=>
! 155: string(13) "Europe/London"
! 156: }
! 157:
! 158: -- empty array --
! 159:
! 160: Warning: DateTime::modify() expects parameter 1 to be string, array given in %sDateTime_modify_variation1.php on line 99
! 161: bool(false)
! 162:
! 163: -- int indexed array --
! 164:
! 165: Warning: DateTime::modify() expects parameter 1 to be string, array given in %sDateTime_modify_variation1.php on line 99
! 166: bool(false)
! 167:
! 168: -- associative array --
! 169:
! 170: Warning: DateTime::modify() expects parameter 1 to be string, array given in %sDateTime_modify_variation1.php on line 99
! 171: bool(false)
! 172:
! 173: -- nested arrays --
! 174:
! 175: Warning: DateTime::modify() expects parameter 1 to be string, array given in %sDateTime_modify_variation1.php on line 99
! 176: bool(false)
! 177:
! 178: -- uppercase NULL --
! 179:
! 180: Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
! 181: bool(false)
! 182:
! 183: -- lowercase null --
! 184:
! 185: Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
! 186: bool(false)
! 187:
! 188: -- lowercase true --
! 189:
! 190: Warning: DateTime::modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in %sDateTime_modify_variation1.php on line 99
! 191: bool(false)
! 192:
! 193: -- lowercase false --
! 194:
! 195: Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
! 196: bool(false)
! 197:
! 198: -- uppercase TRUE --
! 199:
! 200: Warning: DateTime::modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in %sDateTime_modify_variation1.php on line 99
! 201: bool(false)
! 202:
! 203: -- uppercase FALSE --
! 204:
! 205: Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
! 206: bool(false)
! 207:
! 208: -- empty string DQ --
! 209:
! 210: Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
! 211: bool(false)
! 212:
! 213: -- empty string SQ --
! 214:
! 215: Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
! 216: bool(false)
! 217:
! 218: -- string DQ --
! 219:
! 220: Warning: DateTime::modify(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database in %sDateTime_modify_variation1.php on line 99
! 221: bool(false)
! 222:
! 223: -- string SQ --
! 224:
! 225: Warning: DateTime::modify(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database in %sDateTime_modify_variation1.php on line 99
! 226: bool(false)
! 227:
! 228: -- mixed case string --
! 229:
! 230: Warning: DateTime::modify(): Failed to parse time string (sTrInG) at position 0 (s): The timezone could not be found in the database in %sDateTime_modify_variation1.php on line 99
! 231: bool(false)
! 232:
! 233: -- heredoc --
! 234:
! 235: Warning: DateTime::modify(): Failed to parse time string (hello world) at position 0 (h): The timezone could not be found in the database in %sDateTime_modify_variation1.php on line 99
! 236: bool(false)
! 237:
! 238: -- instance of classWithToString --
! 239:
! 240: Warning: DateTime::modify(): Failed to parse time string (Class A object) at position 0 (C): The timezone could not be found in the database in %sDateTime_modify_variation1.php on line 99
! 241: bool(false)
! 242:
! 243: -- instance of classWithoutToString --
! 244:
! 245: Warning: DateTime::modify() expects parameter 1 to be string, object given in %sDateTime_modify_variation1.php on line 99
! 246: bool(false)
! 247:
! 248: -- undefined var --
! 249:
! 250: Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
! 251: bool(false)
! 252:
! 253: -- unset var --
! 254:
! 255: Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
! 256: bool(false)
! 257:
! 258: -- resource --
! 259:
! 260: Warning: DateTime::modify() expects parameter 1 to be string, resource given in %sDateTime_modify_variation1.php on line 99
! 261: bool(false)
! 262: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>