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