Annotation of embedaddon/php/ext/date/tests/idate_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test idate() function : usage variation - Passing unexpected values to second optional argument 'timestamp'.
3: --FILE--
4: <?php
5: /* Prototype : int idate(string format [, int timestamp])
6: * Description: Format a local time/date as integer
7: * Source code: ext/date/php_date.c
8: * Alias to functions:
9: */
10:
11: echo "*** Testing idate() : usage variation ***\n";
12:
13: // Initialise function arguments not being substituted (if any)
14: $format = 'Y';
15: date_default_timezone_set("Asia/Calcutta");
16:
17: //get an unset variable
18: $unset_var = 10;
19: unset ($unset_var);
20:
21: // define some classes
22: class classWithToString
23: {
24: public function __toString() {
25: return "Class A object";
26: }
27: }
28:
29: class classWithoutToString
30: {
31: }
32:
33: // heredoc string
34: $heredoc = <<<EOT
35: hello world
36: EOT;
37:
38: // add arrays
39: $index_array = array (1, 2, 3);
40: $assoc_array = array ('one' => 1, 'two' => 2);
41:
42: //array of values to iterate over
43: $inputs = array(
44:
45: // float data
46: 'float 10.5' => 10.5,
47: 'float -10.5' => -10.5,
48: 'float .5' => .5,
49:
50: // array data
51: 'empty array' => array(),
52: 'int indexed array' => $index_array,
53: 'associative array' => $assoc_array,
54: 'nested arrays' => array('foo', $index_array, $assoc_array),
55:
56: // null data
57: 'uppercase NULL' => NULL,
58: 'lowercase null' => null,
59:
60: // boolean data
61: 'lowercase true' => true,
62: 'lowercase false' =>false,
63: 'uppercase TRUE' =>TRUE,
64: 'uppercase FALSE' =>FALSE,
65:
66: // empty data
67: 'empty string DQ' => "",
68: 'empty string SQ' => '',
69:
70: // string data
71: 'string DQ' => "string",
72: 'string SQ' => 'string',
73: 'mixed case string' => "sTrInG",
74: 'heredoc' => $heredoc,
75:
76: // object data
77: 'instance of classWithToString' => new classWithToString(),
78: 'instance of classWithoutToString' => new classWithoutToString(),
79:
80: // undefined data
81: 'undefined var' => @$undefined_var,
82:
83: // unset data
84: 'unset var' => @$unset_var,
85: );
86:
87: // loop through each element of the array for timestamp
88:
89: foreach($inputs as $key =>$value) {
90: echo "\n--$key--\n";
91: var_dump( idate($format, $value) );
92: };
93:
94: ?>
95: ===DONE===
96: --EXPECTF--
97: *** Testing idate() : usage variation ***
98:
99: --float 10.5--
100: int(1970)
101:
102: --float -10.5--
103: int(1970)
104:
105: --float .5--
106: int(1970)
107:
108: --empty array--
109:
110: Warning: idate() expects parameter 2 to be long, array given in %s on line %d
111: bool(false)
112:
113: --int indexed array--
114:
115: Warning: idate() expects parameter 2 to be long, array given in %s on line %d
116: bool(false)
117:
118: --associative array--
119:
120: Warning: idate() expects parameter 2 to be long, array given in %s on line %d
121: bool(false)
122:
123: --nested arrays--
124:
125: Warning: idate() expects parameter 2 to be long, array given in %s on line %d
126: bool(false)
127:
128: --uppercase NULL--
129: int(1970)
130:
131: --lowercase null--
132: int(1970)
133:
134: --lowercase true--
135: int(1970)
136:
137: --lowercase false--
138: int(1970)
139:
140: --uppercase TRUE--
141: int(1970)
142:
143: --uppercase FALSE--
144: int(1970)
145:
146: --empty string DQ--
147:
148: Warning: idate() expects parameter 2 to be long, string given in %s on line %d
149: bool(false)
150:
151: --empty string SQ--
152:
153: Warning: idate() expects parameter 2 to be long, string given in %s on line %d
154: bool(false)
155:
156: --string DQ--
157:
158: Warning: idate() expects parameter 2 to be long, string given in %s on line %d
159: bool(false)
160:
161: --string SQ--
162:
163: Warning: idate() expects parameter 2 to be long, string given in %s on line %d
164: bool(false)
165:
166: --mixed case string--
167:
168: Warning: idate() expects parameter 2 to be long, string given in %s on line %d
169: bool(false)
170:
171: --heredoc--
172:
173: Warning: idate() expects parameter 2 to be long, string given in %s on line %d
174: bool(false)
175:
176: --instance of classWithToString--
177:
178: Warning: idate() expects parameter 2 to be long, object given in %s on line %d
179: bool(false)
180:
181: --instance of classWithoutToString--
182:
183: Warning: idate() expects parameter 2 to be long, object given in %s on line %d
184: bool(false)
185:
186: --undefined var--
187: int(1970)
188:
189: --unset var--
190: int(1970)
191: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>