Annotation of embedaddon/php/ext/date/tests/gmmktime_variation3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test gmmktime() function : usage variation - Passing unexpected values to third argument seconds.
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: $mon = 8;
17: $day = 8;
18: $year = 2008;
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 -10.5' => -10.5,
51: 'float .5' => .5,
52:
53: // array data
54: 'empty array' => array(),
55: 'int indexed array' => $index_array,
56: 'associative array' => $assoc_array,
57: 'nested arrays' => array('foo', $index_array, $assoc_array),
58:
59: // null data
60: 'uppercase NULL' => NULL,
61: 'lowercase null' => null,
62:
63: // boolean data
64: 'lowercase true' => true,
65: 'lowercase false' =>false,
66: 'uppercase TRUE' =>TRUE,
67: 'uppercase FALSE' =>FALSE,
68:
69: // empty data
70: 'empty string DQ' => "",
71: 'empty string SQ' => '',
72:
73: // string data
74: 'string DQ' => "string",
75: 'string SQ' => 'string',
76: 'mixed case string' => "sTrInG",
77: 'heredoc' => $heredoc,
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 sec
91:
92: foreach($inputs as $key =>$value) {
93: echo "\n--$key--\n";
94: var_dump( gmmktime($hour, $min, $value, $mon, $day, $year) );
95: };
96:
97: ?>
98: ===DONE===
99: --EXPECTF--
100: *** Testing gmmktime() : usage variation ***
101:
102: --float 10.5--
103: int(1218182890)
104:
105: --float -10.5--
106: int(1218182870)
107:
108: --float .5--
109: int(1218182880)
110:
111: --empty array--
112:
113: Warning: gmmktime() expects parameter 3 to be long, array given in %s on line %d
114: bool(false)
115:
116: --int indexed array--
117:
118: Warning: gmmktime() expects parameter 3 to be long, array given in %s on line %d
119: bool(false)
120:
121: --associative array--
122:
123: Warning: gmmktime() expects parameter 3 to be long, array given in %s on line %d
124: bool(false)
125:
126: --nested arrays--
127:
128: Warning: gmmktime() expects parameter 3 to be long, array given in %s on line %d
129: bool(false)
130:
131: --uppercase NULL--
132: int(1218182880)
133:
134: --lowercase null--
135: int(1218182880)
136:
137: --lowercase true--
138: int(1218182881)
139:
140: --lowercase false--
141: int(1218182880)
142:
143: --uppercase TRUE--
144: int(1218182881)
145:
146: --uppercase FALSE--
147: int(1218182880)
148:
149: --empty string DQ--
150:
151: Warning: gmmktime() expects parameter 3 to be long, string given in %s on line %d
152: bool(false)
153:
154: --empty string SQ--
155:
156: Warning: gmmktime() expects parameter 3 to be long, string given in %s on line %d
157: bool(false)
158:
159: --string DQ--
160:
161: Warning: gmmktime() expects parameter 3 to be long, string given in %s on line %d
162: bool(false)
163:
164: --string SQ--
165:
166: Warning: gmmktime() expects parameter 3 to be long, string given in %s on line %d
167: bool(false)
168:
169: --mixed case string--
170:
171: Warning: gmmktime() expects parameter 3 to be long, string given in %s on line %d
172: bool(false)
173:
174: --heredoc--
175:
176: Warning: gmmktime() expects parameter 3 to be long, string given in %s on line %d
177: bool(false)
178:
179: --instance of classWithToString--
180:
181: Warning: gmmktime() expects parameter 3 to be long, object given in %s on line %d
182: bool(false)
183:
184: --instance of classWithoutToString--
185:
186: Warning: gmmktime() expects parameter 3 to be long, object given in %s on line %d
187: bool(false)
188:
189: --undefined var--
190: int(1218182880)
191:
192: --unset var--
193: int(1218182880)
194: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>