Skip to content

Commit c1fb5f1

Browse files
feat: add view render method on testcase
1 parent 5d0893c commit c1fb5f1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/TestCase.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use Tempest\Http\Method;
1313
use Tempest\Http\Request;
1414
use Tempest\Router\HttpApplication;
15+
use Tempest\View\GenericView;
16+
use Tempest\View\View;
17+
use Tempest\View\ViewRenderer;
1518

1619
abstract class TestCase extends IntegrationTest
1720
{
@@ -67,4 +70,15 @@ public static function assertSnippetsMatch(string $expected, string $actual): vo
6770

6871
static::assertSame($expected, $actual);
6972
}
73+
74+
protected function render(string|View $view, mixed ...$params): string
75+
{
76+
if (is_string($view)) {
77+
$view = new GenericView($view);
78+
}
79+
80+
$view->data(...$params);
81+
82+
return $this->container->get(ViewRenderer::class)->render($view);
83+
}
7084
}

0 commit comments

Comments
 (0)