From ea97887cac3b3e8d1d5b70a122fd6fe7e272f5af Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Tue, 4 Jun 2024 21:33:20 -0400 Subject: [PATCH] Flash message is empty for some reason --- app/src/Controller/User/RegisterUserAction.php | 3 ++- app/tests/Controller/User/RegisterUserActionTest.php | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/Controller/User/RegisterUserAction.php b/app/src/Controller/User/RegisterUserAction.php index 7e7c006..c5a445f 100644 --- a/app/src/Controller/User/RegisterUserAction.php +++ b/app/src/Controller/User/RegisterUserAction.php @@ -21,7 +21,8 @@ class RegisterUserAction extends Controller $requestData = $this->request->getParsedBody(); if ($requestData['password'] !== $requestData['checked_password']) { - $this->session->getFlash()->add('error', "Passwords do not match."); + $this->session->getFlash() + ->add('error', "Passwords do not match."); $response = $this->render('user/register.twig'); return $response->withStatus(400); } diff --git a/app/tests/Controller/User/RegisterUserActionTest.php b/app/tests/Controller/User/RegisterUserActionTest.php index 539ba1c..31dfc33 100644 --- a/app/tests/Controller/User/RegisterUserActionTest.php +++ b/app/tests/Controller/User/RegisterUserActionTest.php @@ -54,7 +54,6 @@ class RegisterUserActionTest extends TestCase public function testFailingRegistration(): void { $user = $this->getUser(); - $app = $this->getAppInstance(); /** @var $container \DI\Container */ @@ -75,7 +74,7 @@ class RegisterUserActionTest extends TestCase $flash = $container->get(SessionInterface::class)->getFlash(); $errorMessages = $flash->get('error'); $this->assertIsArray($errorMessages); - $this->assertNotNull($errorMessages); - $this->assertEquals('Unable to register user.', $errorMessage[0]); + $this->assertNotEmpty($errorMessages); + $this->assertEquals('Unable to register user.', $errorMessages[0]); } }