Add the login page, add some comments to the test.

This commit is contained in:
Dave Smith-Hayes 2024-06-16 20:09:09 -04:00
parent 34e45ecaee
commit 4ff2c8cc3a
4 changed files with 39 additions and 2 deletions

View File

@ -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);
}
/**

View File

@ -0,0 +1,14 @@
<?php
namespace Slovocast\Controller\User;
use Psr\Http\Message\ResponseInterface as Response;
use Slovocast\Controller\Controller;
class LoginUserPage extends Controller
{
public function respond(): Response
{
return $this->render('user/login');
}
}

View File

@ -0,0 +1,19 @@
{% extends 'layouts/skeleton.twig' %}
{% block content %}
<div>
<form action="/login" method="post">
<div>
<label for="email">Email<br>
<input name="email" type="text" required>
</div>
<div>
<label for="password">Password<br>
<input name="password" type="password" required>
</div>
<div>
<input type="submit" label="Submit">
</div>
</form>
</div>
{% endblock %}

View File

@ -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