Skip to content

Commit

Permalink
fix + test
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Mar 15, 2024
1 parent 0f8aa16 commit 8619ffc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ViewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(
private DataResponseFactoryInterface $responseFactory,
private Aliases $aliases,
private WebView $view,
?string $viewPath,
?string $viewPath = null,
private ?string $layout = null,
private array $injections = []
) {
Expand Down
14 changes: 14 additions & 0 deletions tests/ViewRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use HttpSoft\Message\ResponseFactory;
use HttpSoft\Message\StreamFactory;
use LogicException;
use PHPUnit\Framework\TestCase;
use ReflectionObject;
use RuntimeException;
Expand Down Expand Up @@ -466,6 +467,19 @@ public function testRenderParametersNotOverrideLayout(): void
$this->assertEqualStringsIgnoringLineEndings($expected, (string) $response->getBody());
}

public function testWithoutViewPath(): void
{
$viewRenderer = new ViewRenderer(
new DataResponseFactory(new ResponseFactory(), new StreamFactory()),
new Aliases(),
new WebView(__DIR__, new SimpleEventDispatcher()),
);

$this->expectException(LogicException::class);
$this->expectExceptionMessage('The view path is not set.');
$viewRenderer->getViewPath();
}

public function testImmutability(): void
{
$original = $this->getRenderer();
Expand Down

0 comments on commit 8619ffc

Please sign in to comment.