Skip to content

Commit e95971e

Browse files
Copilotsamdark
andauthored
Expand test coverage for renderer type validation to include non-object types (#297)
Co-authored-by: samdark <47294+samdark@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 320461b commit e95971e

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

tests/ViewTest.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,62 @@ public function testWithRenderersInvalidRendererTypeThrowsException(): void
262262
]);
263263
}
264264

265+
public function testWithRenderersNullRendererThrowsException(): void
266+
{
267+
$view = TestHelper::createView();
268+
269+
$this->expectException(InvalidArgumentException::class);
270+
$this->expectExceptionMessage(
271+
'Renderer null is not an instance of ' . TemplateRendererInterface::class . '.'
272+
);
273+
274+
$view->withRenderers([
275+
'php' => null,
276+
]);
277+
}
278+
279+
public function testWithRenderersStringRendererThrowsException(): void
280+
{
281+
$view = TestHelper::createView();
282+
283+
$this->expectException(InvalidArgumentException::class);
284+
$this->expectExceptionMessage(
285+
'Renderer string is not an instance of ' . TemplateRendererInterface::class . '.'
286+
);
287+
288+
$view->withRenderers([
289+
'php' => 'invalid-renderer',
290+
]);
291+
}
292+
293+
public function testWithRenderersArrayRendererThrowsException(): void
294+
{
295+
$view = TestHelper::createView();
296+
297+
$this->expectException(InvalidArgumentException::class);
298+
$this->expectExceptionMessage(
299+
'Renderer array is not an instance of ' . TemplateRendererInterface::class . '.'
300+
);
301+
302+
$view->withRenderers([
303+
'php' => [],
304+
]);
305+
}
306+
307+
public function testWithRenderersIntegerRendererThrowsException(): void
308+
{
309+
$view = TestHelper::createView();
310+
311+
$this->expectException(InvalidArgumentException::class);
312+
$this->expectExceptionMessage(
313+
'Renderer int is not an instance of ' . TemplateRendererInterface::class . '.'
314+
);
315+
316+
$view->withRenderers([
317+
'php' => 123,
318+
]);
319+
}
320+
265321
public function testWithRenderersNumericKeyImplicitThrowsException(): void
266322
{
267323
$view = TestHelper::createView();

0 commit comments

Comments
 (0)