mirror of
https://github.com/php/php-src.git
synced 2026-03-30 04:02:19 +02:00
fix test
This commit is contained in:
@@ -7,53 +7,42 @@ Test is_file() function: usage variations - invalid filenames
|
||||
Returns TRUE if the filename exists and is a regular file
|
||||
*/
|
||||
|
||||
/* Testing is_file() with invalid arguments -int, float, bool, NULL, resource */
|
||||
/* Testing is_file() with invalid arguments -int, float, bool, NULL */
|
||||
|
||||
$file_path = __DIR__;
|
||||
$file_handle = fopen($file_path."/is_file_variation3.tmp", "w");
|
||||
function flatten($variable) {
|
||||
\ob_start();
|
||||
\var_dump($variable);
|
||||
$flattened =
|
||||
\ob_get_contents();
|
||||
\ob_end_clean();
|
||||
return \trim($flattened);
|
||||
}
|
||||
|
||||
echo "*** Testing Invalid file types ***\n";
|
||||
$filenames = array(
|
||||
foreach([
|
||||
/* Invalid filenames */
|
||||
-2.34555,
|
||||
" ",
|
||||
"",
|
||||
TRUE,
|
||||
FALSE,
|
||||
NULL,
|
||||
$file_handle,
|
||||
true,
|
||||
false,
|
||||
null,
|
||||
|
||||
/* scalars */
|
||||
1234,
|
||||
0
|
||||
);
|
||||
|
||||
/* loop through to test each element the above array */
|
||||
foreach( $filenames as $filename ) {
|
||||
var_dump( is_file($filename) );
|
||||
] as $filename ) {
|
||||
printf(
|
||||
"%s: %d\n",
|
||||
flatten($filename), @is_file($filename));
|
||||
clearstatcache();
|
||||
}
|
||||
fclose($file_handle);
|
||||
|
||||
echo "\n*** Done ***";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
$file_path = __DIR__;
|
||||
unlink($file_path."/is_file_variation3.tmp");
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing Invalid file types ***
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
Warning: is_file() expects parameter 1 to be a valid path, resource given in %s on line %d
|
||||
NULL
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
*** Done ***
|
||||
float(-2.34555): 0
|
||||
string(1) " ": 0
|
||||
string(0) "": 0
|
||||
bool(true): 0
|
||||
bool(false): 0
|
||||
NULL: 0
|
||||
int(1234): 0
|
||||
int(0): 0
|
||||
|
||||
Reference in New Issue
Block a user