1--TEST--
2Test date_default_timezone_set() function : usage variations - Passing unexpected values for time_zone identifier
3--FILE--
4<?php
5/* Prototype  : bool date_default_timezone_set ( string $timezone_identifier )
6 * Description:  Sets the default timezone used by all date/time functions in a script.
7 * Source code: ext/standard/data/php_date.c
8 */
9
10echo "*** Testing date_default_timezone_set() : usage variations ***\n";
11//get an unset variable
12$unset_var = 10;
13unset ($unset_var);
14
15// heredoc string
16$heredoc = <<<EOT
17abc
18xyz
19EOT;
20
21// get a resource variable
22$fp = fopen(__FILE__, "r");
23
24$inputs = array(
25       // int data
26/*1*/  0,
27       1,
28       12345,
29       -2345,
30
31       // float data
32/*5*/  10.5,
33       -10.5,
34       12.3456789000e10,
35       12.3456789000E-10,
36       .5,
37
38       // null data
39/*10*/ NULL,
40       null,
41
42       // boolean data
43/*12*/ true,
44       false,
45       TRUE,
46       FALSE,
47
48       // empty data
49/*16*/ "",
50       '',
51       array(),
52
53       // string data
54/*19*/ "abcxyz",
55       'abcxyz',
56       $heredoc,
57
58       // undefined data
59/*22*/ @$undefined_var,
60
61       // unset data
62/*23*/ @$unset_var,
63
64       // resource variable
65/*24*/ $fp
66);
67
68// loop through each element of $inputs to check the behaviour of date_default_timezone_set()
69$iterator = 1;
70foreach($inputs as $input) {
71    echo "\n-- Iteration $iterator --\n";
72    var_dump(date_default_timezone_set($input));
73    $iterator++;
74};
75?>
76===Done===
77--EXPECTF--
78*** Testing date_default_timezone_set() : usage variations ***
79
80-- Iteration 1 --
81
82Notice: date_default_timezone_set(): Timezone ID '0' is invalid in %s on line %d
83bool(false)
84
85-- Iteration 2 --
86
87Notice: date_default_timezone_set(): Timezone ID '1' is invalid in %s on line %d
88bool(false)
89
90-- Iteration 3 --
91
92Notice: date_default_timezone_set(): Timezone ID '12345' is invalid in %s on line %d
93bool(false)
94
95-- Iteration 4 --
96
97Notice: date_default_timezone_set(): Timezone ID '-2345' is invalid in %s on line %d
98bool(false)
99
100-- Iteration 5 --
101
102Notice: date_default_timezone_set(): Timezone ID '10.5' is invalid in %s on line %d
103bool(false)
104
105-- Iteration 6 --
106
107Notice: date_default_timezone_set(): Timezone ID '-10.5' is invalid in %s on line %d
108bool(false)
109
110-- Iteration 7 --
111
112Notice: date_default_timezone_set(): Timezone ID '123456789000' is invalid in %s on line %d
113bool(false)
114
115-- Iteration 8 --
116
117Notice: date_default_timezone_set(): Timezone ID '1.23456789E-9' is invalid in %s on line %d
118bool(false)
119
120-- Iteration 9 --
121
122Notice: date_default_timezone_set(): Timezone ID '0.5' is invalid in %s on line %d
123bool(false)
124
125-- Iteration 10 --
126
127Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
128bool(false)
129
130-- Iteration 11 --
131
132Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
133bool(false)
134
135-- Iteration 12 --
136
137Notice: date_default_timezone_set(): Timezone ID '1' is invalid in %s on line %d
138bool(false)
139
140-- Iteration 13 --
141
142Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
143bool(false)
144
145-- Iteration 14 --
146
147Notice: date_default_timezone_set(): Timezone ID '1' is invalid in %s on line %d
148bool(false)
149
150-- Iteration 15 --
151
152Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
153bool(false)
154
155-- Iteration 16 --
156
157Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
158bool(false)
159
160-- Iteration 17 --
161
162Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
163bool(false)
164
165-- Iteration 18 --
166
167Warning: date_default_timezone_set() expects parameter 1 to be string, array given in %s on line %d
168bool(false)
169
170-- Iteration 19 --
171
172Notice: date_default_timezone_set(): Timezone ID 'abcxyz' is invalid in %s on line %d
173bool(false)
174
175-- Iteration 20 --
176
177Notice: date_default_timezone_set(): Timezone ID 'abcxyz' is invalid in %s on line %d
178bool(false)
179
180-- Iteration 21 --
181
182Notice: date_default_timezone_set(): Timezone ID 'abc
183xyz' is invalid in %s on line %d
184bool(false)
185
186-- Iteration 22 --
187
188Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
189bool(false)
190
191-- Iteration 23 --
192
193Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
194bool(false)
195
196-- Iteration 24 --
197
198Warning: date_default_timezone_set() expects parameter 1 to be string, resource given in %s on line %d
199bool(false)
200===Done===
201