Skip to content

Commit b91f759

Browse files
smalyshevJulien Pauli
authored andcommitted
Update tests
Conflicts: ext/standard/tests/dir/opendir_variation1-win32.phpt
1 parent 05b6f25 commit b91f759

File tree

7 files changed

+289
-39
lines changed

7 files changed

+289
-39
lines changed

ext/standard/tests/dir/dir_variation1.phpt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
88
?>
99
--FILE--
1010
<?php
11-
/*
11+
/*
1212
* Prototype : object dir(string $directory[, resource $context])
1313
* Description: Directory class with properties, handle and class and methods read, rewind and close
1414
* Source code: ext/standard/dir.c
@@ -34,7 +34,7 @@ class A
3434
}
3535

3636
// get a resource variable
37-
$fp = fopen(__FILE__, "r"); // get a file handle
37+
$fp = fopen(__FILE__, "r"); // get a file handle
3838
$dfp = opendir( dirname(__FILE__) ); // get a dir handle
3939

4040
// unexpected values to be passed to $directory argument
@@ -92,27 +92,27 @@ echo "Done";
9292

9393
-- Iteration 1 --
9494

95-
Warning: dir() expects parameter 1 to be string, array given in %s on line %d
95+
Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
9696
NULL
9797

9898
-- Iteration 2 --
9999

100-
Warning: dir() expects parameter 1 to be string, array given in %s on line %d
100+
Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
101101
NULL
102102

103103
-- Iteration 3 --
104104

105-
Warning: dir() expects parameter 1 to be string, array given in %s on line %d
105+
Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
106106
NULL
107107

108108
-- Iteration 4 --
109109

110-
Warning: dir() expects parameter 1 to be string, array given in %s on line %d
110+
Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
111111
NULL
112112

113113
-- Iteration 5 --
114114

115-
Warning: dir() expects parameter 1 to be string, array given in %s on line %d
115+
Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
116116
NULL
117117

118118
-- Iteration 6 --
@@ -151,16 +151,16 @@ bool(false)
151151

152152
-- Iteration 16 --
153153

154-
Warning: dir() expects parameter 1 to be string, resource given in %s on line %d
154+
Warning: dir() expects parameter 1 to be a valid path, resource given in %s on line %d
155155
NULL
156156

157157
-- Iteration 17 --
158158

159-
Warning: dir() expects parameter 1 to be string, resource given in %s on line %d
159+
Warning: dir() expects parameter 1 to be a valid path, resource given in %s on line %d
160160
NULL
161161

162162
-- Iteration 18 --
163163

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

ext/standard/tests/dir/opendir_variation1.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
99
--FILE--
1010
<?php
1111
/* Prototype : mixed opendir(string $path[, resource $context])
12-
* Description: Open a directory and return a dir_handle
12+
* Description: Open a directory and return a dir_handle
1313
* Source code: ext/standard/dir.c
1414
*/
1515

@@ -30,7 +30,7 @@ unset ($unset_var);
3030

3131
// get a class
3232
class classA {
33-
33+
3434
var $path;
3535
function __construct($path) {
3636
$this->path = $path;
@@ -73,7 +73,7 @@ $inputs = array(
7373
false,
7474
TRUE,
7575
FALSE,
76-
76+
7777
// empty data
7878
/*16*/ "",
7979
'',
@@ -83,7 +83,7 @@ $inputs = array(
8383
/*19*/ "$path",
8484
'string',
8585
$heredoc,
86-
86+
8787
// object data
8888
/*22*/ new classA($path),
8989

@@ -194,7 +194,7 @@ bool(false)
194194

195195
-- Iteration 18 --
196196

197-
Warning: opendir() expects parameter 1 to be string, array given in %s on line %d
197+
Warning: opendir() expects parameter 1 to be a valid path, array given in %s on line %d
198198
NULL
199199

200200
-- Iteration 19 --
@@ -219,6 +219,6 @@ bool(false)
219219

220220
-- Iteration 25 --
221221

222-
Warning: opendir() expects parameter 1 to be string, resource given in %s on line %d
222+
Warning: opendir() expects parameter 1 to be a valid path, resource given in %s on line %d
223223
NULL
224224
===DONE===

ext/standard/tests/file/mkdir_rmdir_variation2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ bool(false)
6868
Warning: mkdir() expects parameter 1 to be a valid path, string given in %s on line %d
6969
bool(false)
7070

71-
Warning: rmdir(%s): No such file or directory in %s on line %d
71+
Warning: rmdir() expects parameter 1 to be a valid path, string given in %s on line %d
7272
bool(false)
7373

7474
*** Testing mkdir() with miscelleneous input ***

0 commit comments

Comments
 (0)