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