1--TEST--
2Test 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
11echo "*** 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;
22unset ($unset_var);
23
24// define some classes
25class classWithToString
26{
27	public function __toString() {
28		return "Class A object";
29	}
30}
31
32class classWithoutToString
33{
34}
35
36// heredoc string
37$heredoc = <<<EOT
38hello world
39EOT;
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
91foreach($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--
102int(1281254888)
103
104--float .5--
105int(965722088)
106
107--empty array--
108
109Warning: gmmktime() expects parameter 6 to be integer, array given in %s on line %d
110bool(false)
111
112--int indexed array--
113
114Warning: gmmktime() expects parameter 6 to be integer, array given in %s on line %d
115bool(false)
116
117--associative array--
118
119Warning: gmmktime() expects parameter 6 to be integer, array given in %s on line %d
120bool(false)
121
122--nested arrays--
123
124Warning: gmmktime() expects parameter 6 to be integer, array given in %s on line %d
125bool(false)
126
127--uppercase NULL--
128int(965722088)
129
130--lowercase null--
131int(965722088)
132
133--lowercase true--
134int(997258088)
135
136--lowercase false--
137int(965722088)
138
139--uppercase TRUE--
140int(997258088)
141
142--uppercase FALSE--
143int(965722088)
144
145--empty string DQ--
146
147Warning: gmmktime() expects parameter 6 to be integer, string given in %s on line %d
148bool(false)
149
150--empty string SQ--
151
152Warning: gmmktime() expects parameter 6 to be integer, string given in %s on line %d
153bool(false)
154
155--string DQ--
156
157Warning: gmmktime() expects parameter 6 to be integer, string given in %s on line %d
158bool(false)
159
160--string SQ--
161
162Warning: gmmktime() expects parameter 6 to be integer, string given in %s on line %d
163bool(false)
164
165--mixed case string--
166
167Warning: gmmktime() expects parameter 6 to be integer, string given in %s on line %d
168bool(false)
169
170--heredoc--
171
172Warning: gmmktime() expects parameter 6 to be integer, string given in %s on line %d
173bool(false)
174
175--instance of classWithToString--
176
177Warning: gmmktime() expects parameter 6 to be integer, object given in %s on line %d
178bool(false)
179
180--instance of classWithoutToString--
181
182Warning: gmmktime() expects parameter 6 to be integer, object given in %s on line %d
183bool(false)
184
185--undefined var--
186int(965722088)
187
188--unset var--
189int(965722088)
190===DONE===
191