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