1--TEST--
2Test mktime() function : usage variation - Passing unexpected values to first argument $hour.
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 first argument \$hour***\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$sec = 45;
100$month = 7;
101$day = 2;
102$year = 1963;
103$is_dst = 0;
104
105foreach($inputs as $variation =>$hour) {
106      echo "\n-- $variation --\n";
107      var_dump( mktime($hour) );
108};
109
110// closing the resource
111fclose( $file_handle );
112
113?>
114===DONE===
115--EXPECTF--
116*** Testing mktime() : usage variation -  unexpected values to first argument $hour***
117
118-- int 0 --
119int(%i)
120
121-- int 12345 --
122int(%i)
123
124-- int -12345 --
125int(%i)
126
127-- float 10.5 --
128int(%i)
129
130-- float -10.5 --
131int(%i)
132
133-- float .5 --
134int(%i)
135
136-- empty array --
137
138Warning: mktime() expects parameter 1 to be integer, array given in %s on line %d
139bool(false)
140
141-- int indexed array --
142
143Warning: mktime() expects parameter 1 to be integer, array given in %s on line %d
144bool(false)
145
146-- associative array --
147
148Warning: mktime() expects parameter 1 to be integer, array given in %s on line %d
149bool(false)
150
151-- nested arrays --
152
153Warning: mktime() expects parameter 1 to be integer, array given in %s on line %d
154bool(false)
155
156-- uppercase NULL --
157int(%i)
158
159-- lowercase null --
160int(%i)
161
162-- lowercase true --
163int(%i)
164
165-- lowercase false --
166int(%i)
167
168-- uppercase TRUE --
169int(%i)
170
171-- uppercase FALSE --
172int(%i)
173
174-- empty string DQ --
175
176Warning: mktime() expects parameter 1 to be integer, string given in %s on line %d
177bool(false)
178
179-- empty string SQ --
180
181Warning: mktime() expects parameter 1 to be integer, string given in %s on line %d
182bool(false)
183
184-- string DQ --
185
186Warning: mktime() expects parameter 1 to be integer, string given in %s on line %d
187bool(false)
188
189-- string SQ --
190
191Warning: mktime() expects parameter 1 to be integer, string given in %s on line %d
192bool(false)
193
194-- mixed case string --
195
196Warning: mktime() expects parameter 1 to be integer, string given in %s on line %d
197bool(false)
198
199-- heredoc --
200
201Warning: mktime() expects parameter 1 to be integer, string given in %s on line %d
202bool(false)
203
204-- instance of classWithToString --
205
206Warning: mktime() expects parameter 1 to be integer, object given in %s on line %d
207bool(false)
208
209-- instance of classWithoutToString --
210
211Warning: mktime() expects parameter 1 to be integer, object given in %s on line %d
212bool(false)
213
214-- undefined var --
215int(%i)
216
217-- unset var --
218int(%i)
219
220-- resource --
221
222Warning: mktime() expects parameter 1 to be integer, resource given in %s on line %d
223bool(false)
224===DONE===
225