From 4ff2c8cc3a491ca3defaf87d1b22bddd9be6bf4b Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Sun, 16 Jun 2024 20:09:09 -0400 Subject: [PATCH] Add the login page, add some comments to the test. --- app/src/Bootstrap.php | 4 +++- app/src/Controller/User/LoginUserPage.php | 14 ++++++++++++++ app/templates/user/login.twig | 19 +++++++++++++++++++ .../User/RegisterUserActionTest.php | 4 +++- 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 app/src/Controller/User/LoginUserPage.php create mode 100644 app/templates/user/login.twig diff --git a/app/src/Bootstrap.php b/app/src/Bootstrap.php index 728ec4c..8b9a6b9 100644 --- a/app/src/Bootstrap.php +++ b/app/src/Bootstrap.php @@ -124,7 +124,6 @@ class Bootstrap * @var Configuration */ $config = $container->get('config'); - $app->addErrorMiddleware(true, true, true); // Twig $templatePath = __DIR__ . "/../templates"; @@ -140,6 +139,9 @@ class Bootstrap $twig->getEnvironment() ->addGlobal('flash', $flash); $app->add(TwigMiddleware::create($app, $twig)); + + // Add the error handling middleware + $app->addErrorMiddleware(true, true, true); } /** diff --git a/app/src/Controller/User/LoginUserPage.php b/app/src/Controller/User/LoginUserPage.php new file mode 100644 index 0000000..fc87cb9 --- /dev/null +++ b/app/src/Controller/User/LoginUserPage.php @@ -0,0 +1,14 @@ +render('user/login'); + } +} diff --git a/app/templates/user/login.twig b/app/templates/user/login.twig new file mode 100644 index 0000000..47a77ca --- /dev/null +++ b/app/templates/user/login.twig @@ -0,0 +1,19 @@ +{% extends 'layouts/skeleton.twig' %} + +{% block content %} +
+
+
+
+
+
+
+ +
+
+
+{% endblock %} diff --git a/app/tests/Controller/User/RegisterUserActionTest.php b/app/tests/Controller/User/RegisterUserActionTest.php index 95f73c8..45a1f39 100644 --- a/app/tests/Controller/User/RegisterUserActionTest.php +++ b/app/tests/Controller/User/RegisterUserActionTest.php @@ -93,8 +93,10 @@ class RegisterUserActionTest extends TestCase $this->assertEquals(400, $response->getStatusCode()); $responseBody = $response->getBody(); + // get the class of the flash on the rendered page $this->assertTrue((bool)preg_match('/flash error/', $responseBody)); - $this->assertTrue((bool)preg_match('/Unable to register user/', $responseBody)); + // get the text inside the flash + $this->assertTrue((bool)preg_match('/Unable to register user\./', $responseBody)); /** * The Flash messages are already exhausted while rendering the