-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Suppresses warning triggered by `stat`/`lstat` when file does not exit. By injecting another error handler which resets error reporting the suppressed warning gets caught and does not appear in error logs. As certain testing frameworks establish error handlers to pick up on suppressed errors, exceptions and warnings, the warning generated by `stat`/`lstat` when provided an unknown path is recorded.
- Loading branch information
Showing
2 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
// test that overloaded "exists-check" functions (see php-src/ext/standard/filestat.c) must not invoke the error handler | ||
|
||
declare(strict_types=1); | ||
|
||
use Tester\Assert; | ||
|
||
require __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
Tester\Environment::setup(); | ||
|
||
DG\BypassFinals::enable(); | ||
|
||
|
||
function thoroughErrorHandler(): void | ||
{ | ||
throw new Exception('This must not happen'); | ||
} | ||
|
||
|
||
Assert::noError(function () { | ||
set_error_handler('thoroughErrorHandler'); | ||
|
||
file_exists('unknown'); | ||
|
||
restore_error_handler(); | ||
}); | ||
|
||
Assert::noError(function () { | ||
set_error_handler('thoroughErrorHandler'); | ||
|
||
is_writable('unknown'); | ||
|
||
restore_error_handler(); | ||
}); | ||
|
||
Assert::noError(function () { | ||
set_error_handler('thoroughErrorHandler'); | ||
|
||
is_readable('unknown'); | ||
|
||
restore_error_handler(); | ||
}); | ||
|
||
Assert::noError(function () { | ||
set_error_handler('thoroughErrorHandler'); | ||
|
||
is_executable('unknown'); | ||
|
||
restore_error_handler(); | ||
}); | ||
|
||
Assert::noError(function () { | ||
set_error_handler('thoroughErrorHandler'); | ||
|
||
is_file('unknown'); | ||
|
||
restore_error_handler(); | ||
}); | ||
|
||
Assert::noError(function () { | ||
set_error_handler('thoroughErrorHandler'); | ||
|
||
is_dir('unknown'); | ||
|
||
restore_error_handler(); | ||
}); | ||
|
||
Assert::noError(function () { | ||
set_error_handler('thoroughErrorHandler'); | ||
|
||
is_link('unknown'); | ||
|
||
restore_error_handler(); | ||
}); |