From 2543915e51fa8d1e02640acb250f1410787223ad Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Thu, 21 Sep 2017 16:24:30 +0200 Subject: [PATCH] TestCase throws an Exception if the file is not readable --- tests/Sniffs/TestCase.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Sniffs/TestCase.php b/tests/Sniffs/TestCase.php index 3b3f3b9..7558267 100644 --- a/tests/Sniffs/TestCase.php +++ b/tests/Sniffs/TestCase.php @@ -24,6 +24,13 @@ public function __construct(string $name = null, array $data = [], string $dataN protected function checkFile(string $filePath): PhpCsFile { + if (!is_readable($filePath)) { + throw new \Exception(sprintf( + 'File "%s" is not readable', + $filePath + )); + } + $codeSniffer = new PhpCsRunner(); $codeSniffer->config = new PhpCsConfig([ '-s', // showSources must be on, so that errors are recorded