Skip to content

Commit 6f9a06c

Browse files
committed
this test is flaky on azure, and can't see why from current output
so refactored, and restored an accidentally removed check (resource)
1 parent 3f4dfe1 commit 6f9a06c

File tree

1 file changed

+29
-36
lines changed

1 file changed

+29
-36
lines changed

ext/standard/tests/file/is_file_variation3.phpt

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,44 @@ Test is_file() function: usage variations - invalid filenames
99

1010
/* Testing is_file() with invalid arguments -int, float, bool, NULL, resource */
1111

12-
$file_path = __DIR__;
13-
$file_handle = fopen($file_path."/is_file_variation3.tmp", "w");
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,
28-
0
29-
);
30-
31-
/* loop through to test each element the above array */
32-
foreach( $filenames as $filename ) {
33-
var_dump( is_file($filename) );
32+
0,
33+
34+
/* resource */
35+
fopen(__FILE__, "r")
36+
] as $filename ) {
37+
printf(
38+
"%s: %d\n",
39+
flatten($filename), @is_file($filename));
3440
clearstatcache();
3541
}
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");
4442
?>
4543
--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 ***
44+
float(-2.34555): 0
45+
string(1) " ": 0
46+
string(0) "": 0
47+
bool(true): 0
48+
bool(false): 0
49+
NULL: 0
50+
int(1234): 0
51+
int(0): 0
52+
resource(%d) of type (stream): 0

0 commit comments

Comments
 (0)