From f5d7a466f3d708a9493e339d50c79c0eaf98e042 Mon Sep 17 00:00:00 2001 From: veltrup Date: Thu, 7 Dec 2023 17:55:39 +0100 Subject: [PATCH] fix: code review fixes --- src/Loader/SiteKitLoader.php | 8 ++--- ...umentRootLayoutResourceBaseLocatorTest.php | 34 ++++++++++++------- .../ResourceLayoutResourceBaseLocatorTest.php | 34 ++++++++++++------- 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/src/Loader/SiteKitLoader.php b/src/Loader/SiteKitLoader.php index 70d7037..9603b6a 100644 --- a/src/Loader/SiteKitLoader.php +++ b/src/Loader/SiteKitLoader.php @@ -47,11 +47,9 @@ public function load(string $location): Resource public function exists(string $location): bool { - return file_exists( - $this->baseLocator->locate() . - DIRECTORY_SEPARATOR . - $location - ); + return file_exists($this->baseLocator->locate() + . DIRECTORY_SEPARATOR + . $location); } /** diff --git a/test/Loader/DocumentRootLayoutResourceBaseLocatorTest.php b/test/Loader/DocumentRootLayoutResourceBaseLocatorTest.php index 8acac0c..f0fd119 100644 --- a/test/Loader/DocumentRootLayoutResourceBaseLocatorTest.php +++ b/test/Loader/DocumentRootLayoutResourceBaseLocatorTest.php @@ -17,20 +17,30 @@ #[CoversClass(DocumentRootLayoutResourceBaseLocator::class)] class DocumentRootLayoutResourceBaseLocatorTest extends TestCase { + /** + * @var array + */ + private array $saveServerState; + + public function setUp(): void + { + $this->saveServerState = $_SERVER; + } + + public function tearDown(): void + { + $_SERVER = $this->saveServerState; + } + public function testConstruct(): void { - $saveServerState = $_SERVER; - try { - $_SERVER['DOCUMENT_ROOT'] = 'abc'; - $locator = new DocumentRootLayoutResourceBaseLocator(); - $this->assertEquals( - 'abc', - $locator->locate(), - 'unexpected resource base' - ); - } finally { - $_SERVER = $saveServerState; - } + $_SERVER['DOCUMENT_ROOT'] = 'abc'; + $locator = new DocumentRootLayoutResourceBaseLocator(); + $this->assertEquals( + 'abc', + $locator->locate(), + 'unexpected resource base' + ); } public function testWithMissingSeverVariable(): void diff --git a/test/Loader/ResourceLayoutResourceBaseLocatorTest.php b/test/Loader/ResourceLayoutResourceBaseLocatorTest.php index a253a0f..e2dce57 100644 --- a/test/Loader/ResourceLayoutResourceBaseLocatorTest.php +++ b/test/Loader/ResourceLayoutResourceBaseLocatorTest.php @@ -14,20 +14,30 @@ #[CoversClass(ResourceLayoutResourceBaseLocator::class)] class ResourceLayoutResourceBaseLocatorTest extends TestCase { + /** + * @var array + */ + private array $saveServerState; + + public function setUp(): void + { + $this->saveServerState = $_SERVER; + } + + public function tearDown(): void + { + $_SERVER = $this->saveServerState; + } + public function testConstruct(): void { - $saveServerState = $_SERVER; - try { - $_SERVER['RESOURCE_ROOT'] = 'abc'; - $locator = new ResourceLayoutResourceBaseLocator(); - $this->assertEquals( - 'abc/objects', - $locator->locate(), - 'unexpected resource base' - ); - } finally { - $_SERVER = $saveServerState; - } + $_SERVER['RESOURCE_ROOT'] = 'abc'; + $locator = new ResourceLayoutResourceBaseLocator(); + $this->assertEquals( + 'abc/objects', + $locator->locate(), + 'unexpected resource base' + ); } public function testWithMissingSeverVariable(): void