Skip to content

Commit

Permalink
fix: code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sitepark-veltrup committed Dec 7, 2023
1 parent 22eddd5 commit f5d7a46
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 29 deletions.
8 changes: 3 additions & 5 deletions src/Loader/SiteKitLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
34 changes: 22 additions & 12 deletions test/Loader/DocumentRootLayoutResourceBaseLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,30 @@
#[CoversClass(DocumentRootLayoutResourceBaseLocator::class)]
class DocumentRootLayoutResourceBaseLocatorTest extends TestCase
{
/**
* @var array<string,string>
*/
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
Expand Down
34 changes: 22 additions & 12 deletions test/Loader/ResourceLayoutResourceBaseLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,30 @@
#[CoversClass(ResourceLayoutResourceBaseLocator::class)]
class ResourceLayoutResourceBaseLocatorTest extends TestCase
{
/**
* @var array<string,string>
*/
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
Expand Down

0 comments on commit f5d7a46

Please sign in to comment.