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