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