1--TEST--
2Test chdir() function : usage variations - different data type as $directory arg
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) != 'WIN') {
6  die("skip Valid only on Windows");
7}
8?>
9--FILE--
10<?php
11/* Prototype  : bool chdir(string $directory)
12 * Description: Change the current directory
13 * Source code: ext/standard/dir.c
14 */
15
16/*
17 * Pass different data types as $directory argument to test behaviour
18 */
19
20echo "*** Testing chdir() : usage variations ***\n";
21
22// create the temporary directory
23$file_path = dirname(__FILE__);
24$dir_path = $file_path."/私はガラスを食べられますchdir_basic";
25@mkdir($dir_path);
26
27//get an unset variable
28$unset_var = 10;
29unset ($unset_var);
30
31// get a class
32class classA {
33	var $dir_path;
34
35	function __construct($dir) {
36		$this->dir_path = $dir;
37	}
38
39	public function __toString() {
40		return "$this->dir_path";
41	}
42}
43
44// heredoc string
45$heredoc = <<<EOT
46$dir_path
47EOT;
48
49// get a resource variable
50$fp = fopen(__FILE__, "r");
51
52// unexpected values to be passed to $directory argument
53$inputs = array(
54
55       // int data
56/*1*/  0,
57       1,
58       12345,
59       -2345,
60
61       // float data
62/*5*/  10.5,
63       -10.5,
64       12.3456789000e10,
65       12.3456789000E-10,
66       .5,
67
68       // null data
69/*10*/ NULL,
70       null,
71
72       // boolean data
73/*12*/ true,
74       false,
75       TRUE,
76       FALSE,
77
78       // empty data
79/*16*/ "",
80       '',
81       array(),
82
83       // string data
84/*19*/ "$dir_path",
85       'string',
86       $heredoc,
87
88       // object data
89/*22*/ new classA($dir_path),
90
91       // undefined data
92/*23*/ @$undefined_var,
93
94       // unset data
95/*24*/ @$unset_var,
96
97       // resource variable
98/*25*/ $fp
99);
100
101// loop through each element of $inputs to check the behavior of chdir()
102$iterator = 1;
103foreach($inputs as $input) {
104  echo "\n-- Iteration $iterator --\n";
105  var_dump( chdir($input) );
106  $iterator++;
107};
108
109fclose($fp);
110
111?>
112===DONE===
113--CLEAN--
114<?php
115$file_path = dirname(__FILE__);
116$dir_path = $file_path."/私はガラスを食べられますchdir_basic";
117
118rmdir($dir_path);
119?>
120--EXPECTF--
121*** Testing chdir() : usage variations ***
122
123-- Iteration 1 --
124
125Warning: chdir(): %s (errno %d) in %s on line %d
126bool(false)
127
128-- Iteration 2 --
129
130Warning: chdir(): %s (errno %d) in %s on line %d
131bool(false)
132
133-- Iteration 3 --
134
135Warning: chdir(): %s (errno %d) in %s on line %d
136bool(false)
137
138-- Iteration 4 --
139
140Warning: chdir(): %s (errno %d) in %s on line %d
141bool(false)
142
143-- Iteration 5 --
144
145Warning: chdir(): %s (errno %d) in %s on line %d
146bool(false)
147
148-- Iteration 6 --
149
150Warning: chdir(): %s (errno %d) in %s on line %d
151bool(false)
152
153-- Iteration 7 --
154
155Warning: chdir(): %s (errno %d) in %s on line %d
156bool(false)
157
158-- Iteration 8 --
159
160Warning: chdir(): %s (errno %d) in %s on line %d
161bool(false)
162
163-- Iteration 9 --
164
165Warning: chdir(): %s (errno %d) in %s on line %d
166bool(false)
167
168-- Iteration 10 --
169
170Warning: chdir(): %s (errno %d) in %s on line %d
171bool(false)
172
173-- Iteration 11 --
174
175Warning: chdir(): %s (errno %d) in %s on line %d
176bool(false)
177
178-- Iteration 12 --
179
180Warning: chdir(): %s (errno %d) in %s on line %d
181bool(false)
182
183-- Iteration 13 --
184
185Warning: chdir(): %s (errno %d) in %s on line %d
186bool(false)
187
188-- Iteration 14 --
189
190Warning: chdir(): %s (errno %d) in %s on line %d
191bool(false)
192
193-- Iteration 15 --
194
195Warning: chdir(): %s (errno %d) in %s on line %d
196bool(false)
197
198-- Iteration 16 --
199
200Warning: chdir(): %s (errno %d) in %s on line %d
201bool(false)
202
203-- Iteration 17 --
204
205Warning: chdir(): %s (errno %d) in %s on line %d
206bool(false)
207
208-- Iteration 18 --
209
210Warning: chdir() expects parameter 1 to be a valid path, array given in %s on line %d
211bool(false)
212
213-- Iteration 19 --
214bool(true)
215
216-- Iteration 20 --
217
218Warning: chdir(): %s (errno %d) in %s on line %d
219bool(false)
220
221-- Iteration 21 --
222bool(true)
223
224-- Iteration 22 --
225bool(true)
226
227-- Iteration 23 --
228
229Warning: chdir(): %s (errno %d) in %s on line %d
230bool(false)
231
232-- Iteration 24 --
233
234Warning: chdir(): %s (errno %d) in %s on line %d
235bool(false)
236
237-- Iteration 25 --
238
239Warning: chdir() expects parameter 1 to be a valid path, resource given in %s on line %d
240bool(false)
241===DONE===
242