mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
3b0e61956e
the old flag check was flawed and would miss some flags, for example: file(__FILE__, FILE_APPEND); is invalid, but the old flags error check would miss it: https://3v4l.org/b2W9u Closes GH-11483
39 lines
993 B
PHP
39 lines
993 B
PHP
--TEST--
|
|
Test file() function : error conditions
|
|
--FILE--
|
|
<?php
|
|
$file_path = __DIR__;
|
|
echo "\n*** Testing error conditions ***\n";
|
|
$file_handle = fopen($file_path."/file.tmp", "w");
|
|
|
|
$filename = $file_path."/file.tmp";
|
|
try {
|
|
var_dump( file($filename, 10, NULL) ); // Incorrect flag
|
|
} catch(ValueError $e) {
|
|
echo "ValueError: " . $e->getMessage() . "\n";
|
|
}
|
|
try {
|
|
var_dump( file($filename, FILE_APPEND) ); // Incorrect flag
|
|
} catch(ValueError $e) {
|
|
echo "ValueError: " . $e->getMessage() . "\n";
|
|
}
|
|
var_dump( file("temp.tmp") ); // non existing filename
|
|
fclose($file_handle);
|
|
|
|
echo "\n--- Done ---";
|
|
?>
|
|
--CLEAN--
|
|
<?php
|
|
$file_path = __DIR__;
|
|
unlink($file_path."/file.tmp");
|
|
?>
|
|
--EXPECTF--
|
|
*** Testing error conditions ***
|
|
ValueError: file(): Argument #2 ($flags) must be a valid flag value
|
|
ValueError: file(): Argument #2 ($flags) must be a valid flag value
|
|
|
|
Warning: file(temp.tmp): Failed to open stream: No such file or directory in %s on line %d
|
|
bool(false)
|
|
|
|
--- Done ---
|