Annotation of embedaddon/php/ext/date/tests/idate_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test idate() function : usage variation - Passing unexpected values to first argument 'format'.
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: date_default_timezone_set("Asia/Calcutta");
15: $timestamp = mktime(8, 8, 8, 8, 8, 2008);
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: // int data
46: 'int 0' => 0,
47: 'int 1' => 1,
48: 'int 12345' => 12345,
49: 'int -12345' => -12345,
50:
51: // float data
52: 'float 10.5' => 10.5,
53: 'float -10.5' => -10.5,
54: 'float 12.3456789000e10' => 12.3456789000e10,
55: 'float -12.3456789000e10' => -12.3456789000e10,
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: // object data
79: 'instance of classWithToString' => new classWithToString(),
80: 'instance of classWithoutToString' => new classWithoutToString(),
81:
82: // undefined data
83: 'undefined var' => @$undefined_var,
84:
85: // unset data
86: 'unset var' => @$unset_var,
87: );
88:
89: // loop through each element of the array for format
90:
91: foreach($inputs as $key =>$value) {
92: echo "\n--$key--\n";
93: var_dump( idate($value) );
94: var_dump( idate($value, $timestamp) );
95: };
96:
97: ?>
98: ===DONE===
99: --EXPECTF--
100: *** Testing idate() : usage variation ***
101:
102: --int 0--
103:
104: Warning: idate(): Unrecognized date format token. in %s on line %d
105: bool(false)
106:
107: Warning: idate(): Unrecognized date format token. in %s on line %d
108: bool(false)
109:
110: --int 1--
111:
112: Warning: idate(): Unrecognized date format token. in %s on line %d
113: bool(false)
114:
115: Warning: idate(): Unrecognized date format token. in %s on line %d
116: bool(false)
117:
118: --int 12345--
119:
120: Warning: idate(): idate format is one char in %s on line %d
121: bool(false)
122:
123: Warning: idate(): idate format is one char in %s on line %d
124: bool(false)
125:
126: --int -12345--
127:
128: Warning: idate(): idate format is one char in %s on line %d
129: bool(false)
130:
131: Warning: idate(): idate format is one char in %s on line %d
132: bool(false)
133:
134: --float 10.5--
135:
136: Warning: idate(): idate format is one char in %s on line %d
137: bool(false)
138:
139: Warning: idate(): idate format is one char in %s on line %d
140: bool(false)
141:
142: --float -10.5--
143:
144: Warning: idate(): idate format is one char in %s on line %d
145: bool(false)
146:
147: Warning: idate(): idate format is one char in %s on line %d
148: bool(false)
149:
150: --float 12.3456789000e10--
151:
152: Warning: idate(): idate format is one char in %s on line %d
153: bool(false)
154:
155: Warning: idate(): idate format is one char in %s on line %d
156: bool(false)
157:
158: --float -12.3456789000e10--
159:
160: Warning: idate(): idate format is one char in %s on line %d
161: bool(false)
162:
163: Warning: idate(): idate format is one char in %s on line %d
164: bool(false)
165:
166: --float .5--
167:
168: Warning: idate(): idate format is one char in %s on line %d
169: bool(false)
170:
171: Warning: idate(): idate format is one char in %s on line %d
172: bool(false)
173:
174: --empty array--
175:
176: Warning: idate() expects parameter 1 to be string, array given in %s on line %d
177: bool(false)
178:
179: Warning: idate() expects parameter 1 to be string, array given in %s on line %d
180: bool(false)
181:
182: --int indexed array--
183:
184: Warning: idate() expects parameter 1 to be string, array given in %s on line %d
185: bool(false)
186:
187: Warning: idate() expects parameter 1 to be string, array given in %s on line %d
188: bool(false)
189:
190: --associative array--
191:
192: Warning: idate() expects parameter 1 to be string, array given in %s on line %d
193: bool(false)
194:
195: Warning: idate() expects parameter 1 to be string, array given in %s on line %d
196: bool(false)
197:
198: --nested arrays--
199:
200: Warning: idate() expects parameter 1 to be string, array given in %s on line %d
201: bool(false)
202:
203: Warning: idate() expects parameter 1 to be string, array given in %s on line %d
204: bool(false)
205:
206: --uppercase NULL--
207:
208: Warning: idate(): idate format is one char in %s on line %d
209: bool(false)
210:
211: Warning: idate(): idate format is one char in %s on line %d
212: bool(false)
213:
214: --lowercase null--
215:
216: Warning: idate(): idate format is one char in %s on line %d
217: bool(false)
218:
219: Warning: idate(): idate format is one char in %s on line %d
220: bool(false)
221:
222: --lowercase true--
223:
224: Warning: idate(): Unrecognized date format token. in %s on line %d
225: bool(false)
226:
227: Warning: idate(): Unrecognized date format token. in %s on line %d
228: bool(false)
229:
230: --lowercase false--
231:
232: Warning: idate(): idate format is one char in %s on line %d
233: bool(false)
234:
235: Warning: idate(): idate format is one char in %s on line %d
236: bool(false)
237:
238: --uppercase TRUE--
239:
240: Warning: idate(): Unrecognized date format token. in %s on line %d
241: bool(false)
242:
243: Warning: idate(): Unrecognized date format token. in %s on line %d
244: bool(false)
245:
246: --uppercase FALSE--
247:
248: Warning: idate(): idate format is one char in %s on line %d
249: bool(false)
250:
251: Warning: idate(): idate format is one char in %s on line %d
252: bool(false)
253:
254: --empty string DQ--
255:
256: Warning: idate(): idate format is one char in %s on line %d
257: bool(false)
258:
259: Warning: idate(): idate format is one char in %s on line %d
260: bool(false)
261:
262: --empty string SQ--
263:
264: Warning: idate(): idate format is one char in %s on line %d
265: bool(false)
266:
267: Warning: idate(): idate format is one char in %s on line %d
268: bool(false)
269:
270: --instance of classWithToString--
271:
272: Warning: idate(): idate format is one char in %s on line %d
273: bool(false)
274:
275: Warning: idate(): idate format is one char in %s on line %d
276: bool(false)
277:
278: --instance of classWithoutToString--
279:
280: Warning: idate() expects parameter 1 to be string, object given in %s on line %d
281: bool(false)
282:
283: Warning: idate() expects parameter 1 to be string, object given in %s on line %d
284: bool(false)
285:
286: --undefined var--
287:
288: Warning: idate(): idate format is one char in %s on line %d
289: bool(false)
290:
291: Warning: idate(): idate format is one char in %s on line %d
292: bool(false)
293:
294: --unset var--
295:
296: Warning: idate(): idate format is one char in %s on line %d
297: bool(false)
298:
299: Warning: idate(): idate format is one char in %s on line %d
300: bool(false)
301: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>