diff --git a/tests/ViewTest.php b/tests/ViewTest.php index 162a46ba0..e4e5b419c 100644 --- a/tests/ViewTest.php +++ b/tests/ViewTest.php @@ -262,6 +262,62 @@ public function testWithRenderersInvalidRendererTypeThrowsException(): void ]); } + public function testWithRenderersNullRendererThrowsException(): void + { + $view = TestHelper::createView(); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage( + 'Renderer null is not an instance of ' . TemplateRendererInterface::class . '.' + ); + + $view->withRenderers([ + 'php' => null, + ]); + } + + public function testWithRenderersStringRendererThrowsException(): void + { + $view = TestHelper::createView(); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage( + 'Renderer string is not an instance of ' . TemplateRendererInterface::class . '.' + ); + + $view->withRenderers([ + 'php' => 'invalid-renderer', + ]); + } + + public function testWithRenderersArrayRendererThrowsException(): void + { + $view = TestHelper::createView(); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage( + 'Renderer array is not an instance of ' . TemplateRendererInterface::class . '.' + ); + + $view->withRenderers([ + 'php' => [], + ]); + } + + public function testWithRenderersIntegerRendererThrowsException(): void + { + $view = TestHelper::createView(); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage( + 'Renderer int is not an instance of ' . TemplateRendererInterface::class . '.' + ); + + $view->withRenderers([ + 'php' => 123, + ]); + } + public function testWithRenderersNumericKeyImplicitThrowsException(): void { $view = TestHelper::createView();