From 2ab50201fa5167acea1fe5997983a8a79eabe9c9 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 20 Jun 2023 09:19:57 +0200 Subject: [PATCH] [TASK] Make the controller tests more fine-grained (#856) Tests should only test one thing (if possible). --- Tests/Unit/Controller/TeaControllerTest.php | 30 +++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/Tests/Unit/Controller/TeaControllerTest.php b/Tests/Unit/Controller/TeaControllerTest.php index 812f172..a60bb8b 100644 --- a/Tests/Unit/Controller/TeaControllerTest.php +++ b/Tests/Unit/Controller/TeaControllerTest.php @@ -77,10 +77,17 @@ final class TeaControllerTest extends UnitTestCase $this->teaRepositoryMock->method('findAll')->willReturn($teas); $this->viewMock->expects(self::once())->method('assign')->with('teas', $teas); - self::assertInstanceOf( - HtmlResponse::class, - $this->subject->indexAction() - ); + $this->subject->indexAction(); + } + + /** + * @test + */ + public function indexActionReturnsHtmlResponse(): void + { + $result = $this->subject->indexAction(); + + self::assertInstanceOf(HtmlResponse::class, $result); } /** @@ -91,9 +98,16 @@ final class TeaControllerTest extends UnitTestCase $tea = new Tea(); $this->viewMock->expects(self::once())->method('assign')->with('tea', $tea); - self::assertInstanceOf( - HtmlResponse::class, - $this->subject->showAction($tea) - ); + $this->subject->showAction($tea); + } + + /** + * @test + */ + public function showActionAssignsReturnsHtmlResponse(): void + { + $result = $this->subject->showAction(new Tea()); + + self::assertInstanceOf(HtmlResponse::class, $result); } }