From 34e45ecaee43e4623e8a5a62117acd233ffc270c Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Sun, 16 Jun 2024 07:35:27 -0400 Subject: [PATCH] Update the tests for the flash messages. --- app/tests/Controller/User/RegisterUserActionTest.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/tests/Controller/User/RegisterUserActionTest.php b/app/tests/Controller/User/RegisterUserActionTest.php index cafd73b..95f73c8 100644 --- a/app/tests/Controller/User/RegisterUserActionTest.php +++ b/app/tests/Controller/User/RegisterUserActionTest.php @@ -92,11 +92,19 @@ class RegisterUserActionTest extends TestCase $response = $app->handle($request); $this->assertEquals(400, $response->getStatusCode()); + $responseBody = $response->getBody(); + $this->assertTrue((bool)preg_match('/flash error/', $responseBody)); + $this->assertTrue((bool)preg_match('/Unable to register user/', $responseBody)); + + /** + * The Flash messages are already exhausted while rendering the + * templates. We should check the template for the error. + */ $flash = $container->get(SessionInterface::class)->getFlash(); $errorMessages = $flash->get('error'); $this->assertIsArray($errorMessages); - $this->assertNotEmpty($errorMessages); - $this->assertEquals('Unable to register user.', $errorMessages[0]); + //$this->assertNotEmpty($errorMessages); + //$this->assertEquals('Unable to register user.', $errorMessages[0]); } public function testMismatchPassword(): void