Skip to content

Commit

Permalink
refactor: better handling of missing RESOURCE_ROOT
Browse files Browse the repository at this point in the history
  • Loading branch information
sitepark-veltrup committed Jun 14, 2024
1 parent c6c62e3 commit 2261f1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parameters:
atoolo_resource.resource_root: '%env(RESOURCE_ROOT)%'
atoolo_resource.resource_host: '%env(RESOURCE_HOST)%'
atoolo_resource.resource_root: '%env(default::string:RESOURCE_ROOT)%'
atoolo_resource.resource_host: '%env(default::string:RESOURCE_HOST)%'

services:

Expand Down
5 changes: 5 additions & 0 deletions src/SiteKitResourceChannelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class SiteKitResourceChannelFactory implements ResourceChannelFactory
public function __construct(
private readonly string $baseDir
) {
if (empty($this->baseDir)) {
throw new RuntimeException(
'RESOURCE_ROOT not set'
);
}
}

public function create(): ResourceChannel
Expand Down
6 changes: 6 additions & 0 deletions test/SiteKitResourceChannelFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,10 @@ public function testCreateWithInvalidContextPhp(): void
$this->expectException(\RuntimeException::class);
$factory->create();
}

public function testEmptyBaseDIr(): void
{
$this->expectException(\RuntimeException::class);
new SiteKitResourceChannelFactory('');
}
}

0 comments on commit 2261f1f

Please sign in to comment.