Skip to content

Commit d6f93ca

Browse files
committed
fix test
1 parent 69f6458 commit d6f93ca

File tree

1 file changed

+26
-37
lines changed

1 file changed

+26
-37
lines changed

ext/standard/tests/file/is_file_variation3.phpt

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,42 @@ Test is_file() function: usage variations - invalid filenames
77
Returns TRUE if the filename exists and is a regular file
88
*/
99

10-
/* Testing is_file() with invalid arguments -int, float, bool, NULL, resource */
11-
12-
$file_path = __DIR__;
13-
$file_handle = fopen($file_path."/is_file_variation3.tmp", "w");
10+
/* Testing is_file() with invalid arguments -int, float, bool, NULL */
11+
12+
function flatten($variable) {
13+
\ob_start();
14+
\var_dump($variable);
15+
$flattened =
16+
\ob_get_contents();
17+
\ob_end_clean();
18+
return \trim($flattened);
19+
}
1420

15-
echo "*** Testing Invalid file types ***\n";
16-
$filenames = array(
21+
foreach([
1722
/* Invalid filenames */
1823
-2.34555,
1924
" ",
2025
"",
21-
TRUE,
22-
FALSE,
23-
NULL,
24-
$file_handle,
26+
true,
27+
false,
28+
null,
2529

2630
/* scalars */
2731
1234,
2832
0
29-
);
30-
31-
/* loop through to test each element the above array */
32-
foreach( $filenames as $filename ) {
33-
var_dump( is_file($filename) );
33+
] as $filename ) {
34+
printf(
35+
"%s: %d\n",
36+
flatten($filename), @is_file($filename));
3437
clearstatcache();
3538
}
36-
fclose($file_handle);
37-
38-
echo "\n*** Done ***";
39-
?>
40-
--CLEAN--
41-
<?php
42-
$file_path = __DIR__;
43-
unlink($file_path."/is_file_variation3.tmp");
4439
?>
4540
--EXPECTF--
46-
*** Testing Invalid file types ***
47-
bool(false)
48-
bool(false)
49-
bool(false)
50-
bool(false)
51-
bool(false)
52-
bool(false)
53-
54-
Warning: is_file() expects parameter 1 to be a valid path, resource given in %s on line %d
55-
NULL
56-
bool(false)
57-
bool(false)
58-
59-
*** Done ***
41+
float(-2.34555): 0
42+
string(1) " ": 0
43+
string(0) "": 0
44+
bool(true): 0
45+
bool(false): 0
46+
NULL: 0
47+
int(1234): 0
48+
int(0): 0

0 commit comments

Comments
 (0)