diff --git a/src/TextUI/Command.php b/src/TextUI/Command.php index 9b66bc19272..e801368d351 100644 --- a/src/TextUI/Command.php +++ b/src/TextUI/Command.php @@ -778,7 +778,17 @@ protected function handleArguments(array $argv): void } if (isset($this->options[1][1])) { - $this->arguments['testFile'] = \realpath($this->options[1][1]); + $testFile = \realpath($this->options[1][1]); + + if ($testFile === false) { + $this->exitWithErrorMessage( + \sprintf( + 'Cannot open file "%s".', + $this->options[1][1] + ) + ); + } + $this->arguments['testFile'] = $testFile; } else { $this->arguments['testFile'] = ''; } diff --git a/tests/end-to-end/cli/test-file-not-found.phpt b/tests/end-to-end/cli/test-file-not-found.phpt new file mode 100644 index 00000000000..97a2c7ee617 --- /dev/null +++ b/tests/end-to-end/cli/test-file-not-found.phpt @@ -0,0 +1,12 @@ +--TEST-- +Test incorrect testFile is reported +--ARGS-- +--no-configuration tests nonExistingFile.php +--FILE-- +