Annotation of embedaddon/php/ext/date/tests/gmdate_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test gmdate() function : usage variation - Passing unexpected values to format argument .
3: --FILE--
4: <?php
5: /* Prototype : string gmdate(string format [, long timestamp])
6: * Description: Format a GMT date/time
7: * Source code: ext/date/php_date.c
8: * Alias to functions:
9: */
10:
11: echo "*** Testing gmdate() : usage variation ***\n";
12:
13: // Initialise all required variables
14: date_default_timezone_set('UTC');
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( gmdate($value, $timestamp) );
94: var_dump( gmdate($value) );
95: };
96:
97: ?>
98: ===DONE===
99: --EXPECTF--
100: *** Testing gmdate() : usage variation ***
101:
102: --int 0--
103: string(1) "0"
104: string(1) "0"
105:
106: --int 1--
107: string(1) "1"
108: string(1) "1"
109:
110: --int 12345--
111: string(5) "12345"
112: string(5) "12345"
113:
114: --int -12345--
115: string(6) "-12345"
116: string(6) "-12345"
117:
118: --float 10.5--
119: string(4) "10.5"
120: string(4) "10.5"
121:
122: --float -10.5--
123: string(5) "-10.5"
124: string(5) "-10.5"
125:
126: --float 12.3456789000e10--
127: string(12) "123456789000"
128: string(12) "123456789000"
129:
130: --float -12.3456789000e10--
131: string(13) "-123456789000"
132: string(13) "-123456789000"
133:
134: --float .5--
135: string(3) "0.5"
136: string(3) "0.5"
137:
138: --empty array--
139:
140: Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
141: bool(false)
142:
143: Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
144: bool(false)
145:
146: --int indexed array--
147:
148: Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
149: bool(false)
150:
151: Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
152: bool(false)
153:
154: --associative array--
155:
156: Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
157: bool(false)
158:
159: Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
160: bool(false)
161:
162: --nested arrays--
163:
164: Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
165: bool(false)
166:
167: Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
168: bool(false)
169:
170: --uppercase NULL--
171: string(0) ""
172: string(0) ""
173:
174: --lowercase null--
175: string(0) ""
176: string(0) ""
177:
178: --lowercase true--
179: string(1) "1"
180: string(1) "1"
181:
182: --lowercase false--
183: string(0) ""
184: string(0) ""
185:
186: --uppercase TRUE--
187: string(1) "1"
188: string(1) "1"
189:
190: --uppercase FALSE--
191: string(0) ""
192: string(0) ""
193:
194: --empty string DQ--
195: string(0) ""
196: string(0) ""
197:
198: --empty string SQ--
199: string(0) ""
200: string(0) ""
201:
202: --instance of classWithToString--
203: string(53) "CFridayam0808 AM 2008b8UTC2008-08-08T08:08:08+00:0031"
204: string(%d) "%s"
205:
206: --instance of classWithoutToString--
207:
208: Warning: gmdate() expects parameter 1 to be string, object given in %s on line %d
209: bool(false)
210:
211: Warning: gmdate() expects parameter 1 to be string, object given in %s on line %d
212: bool(false)
213:
214: --undefined var--
215: string(0) ""
216: string(0) ""
217:
218: --unset var--
219: string(0) ""
220: string(0) ""
221: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>