From 2755594d3ce1679c60cd2cb1f0a9c504d83a2e38 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 8 Oct 2020 17:52:52 +0200 Subject: [PATCH] fix file_exists replacement --- Admin/Installer.php | 6 +++++- tests/Admin/AdminTest.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Admin/Installer.php b/Admin/Installer.php index 565689f..7d5789d 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -52,9 +52,13 @@ final class Installer extends InstallerAbstract return; // @codeCoverageIgnore } + if (!\is_file($data['path'] ?? '')) { + throw new PathException($data['path'] ?? ''); + } + $mediaFile = \file_get_contents($data['path'] ?? ''); if ($mediaFile === false) { - throw new PathException($data['path'] ?? ''); + throw new PathException($data['path'] ?? ''); // @codeCoverageIgnore } $mediaData = \json_decode($mediaFile, true); diff --git a/tests/Admin/AdminTest.php b/tests/Admin/AdminTest.php index ba8e330..b43209f 100755 --- a/tests/Admin/AdminTest.php +++ b/tests/Admin/AdminTest.php @@ -36,7 +36,7 @@ class AdminTest extends \PHPUnit\Framework\TestCase public function testInvalidMediaInstallJsonFile() : void { - $this->expectException(\PathException::class); + $this->expectException(\Exception::class); Installer::installExternal($GLOBALS['dbpool'], ['path' => 'invalidJson.json']); }