From ee32d6f926df58c4abd718060d33a6119e395eff Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Wed, 23 Jan 2019 14:16:37 +0100 Subject: [PATCH] fix wrong include filename in user registration (#520) --- .../Registration/confirmed.html.twig | 2 +- .../Registration/register.html.twig | 2 +- .../FOSUserBundle/Resetting/request.html.twig | 2 +- tests/Controller/SecurityControllerTest.php | 105 ++++++++++++++++++ 4 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 tests/Controller/SecurityControllerTest.php diff --git a/templates/bundles/FOSUserBundle/Registration/confirmed.html.twig b/templates/bundles/FOSUserBundle/Registration/confirmed.html.twig index 4ddfbc05..a63f131d 100644 --- a/templates/bundles/FOSUserBundle/Registration/confirmed.html.twig +++ b/templates/bundles/FOSUserBundle/Registration/confirmed.html.twig @@ -1,6 +1,6 @@ {% extends '@AdminLTE/FOSUserBundle/Registration/confirmed.html.twig' %} -{% block logo_login %}{% include 'partials/login_logo.html.twig' %}{% endblock %} +{% block logo_login %}{% include 'partials/logo_login.html.twig' %}{% endblock %} {% block title %}{{ 'browser.title'|trans }}{% endblock %} {% block head %} diff --git a/templates/bundles/FOSUserBundle/Registration/register.html.twig b/templates/bundles/FOSUserBundle/Registration/register.html.twig index 123ec9f7..74deca46 100644 --- a/templates/bundles/FOSUserBundle/Registration/register.html.twig +++ b/templates/bundles/FOSUserBundle/Registration/register.html.twig @@ -1,6 +1,6 @@ {% extends '@AdminLTE/FOSUserBundle/Registration/register.html.twig' %} -{% block logo_login %}{% include 'partials/login_logo.html.twig' %}{% endblock %} +{% block logo_login %}{% include 'partials/logo_login.html.twig' %}{% endblock %} {% block title %}{{ 'browser.title'|trans }}{% endblock %} {% block head %} diff --git a/templates/bundles/FOSUserBundle/Resetting/request.html.twig b/templates/bundles/FOSUserBundle/Resetting/request.html.twig index 96b2f5f2..e766ef08 100644 --- a/templates/bundles/FOSUserBundle/Resetting/request.html.twig +++ b/templates/bundles/FOSUserBundle/Resetting/request.html.twig @@ -1,6 +1,6 @@ {% extends '@AdminLTE/FOSUserBundle/Resetting/request.html.twig' %} -{% block logo_login %}{% include 'partials/login_logo.html.twig' %}{% endblock %} +{% block logo_login %}{% include 'partials/logo_login.html.twig' %}{% endblock %} {% block title %}{{ 'browser.title'|trans }}{% endblock %} {% block head %} diff --git a/tests/Controller/SecurityControllerTest.php b/tests/Controller/SecurityControllerTest.php new file mode 100644 index 00000000..bc1ad42c --- /dev/null +++ b/tests/Controller/SecurityControllerTest.php @@ -0,0 +1,105 @@ +request('GET', '/'); + + $this->assertIsRedirect($client, $this->createUrl('/homepage')); + $client->followRedirect(); + $this->assertIsRedirect($client, $this->createUrl('/login')); + } + + public function testLoginPageIsRendered() + { + $client = self::createClient(); + $this->request($client, '/login'); + + $response = $client->getResponse(); + $this->assertTrue($client->getResponse()->isSuccessful()); + + $content = $response->getContent(); + $this->assertContains('Kimai - Time Tracking', $content); + $this->assertContains('
', $content); + $this->assertContains('assertContains('assertContains('assertContains('">Login', $content); + $this->assertContains('assertContains('Register a new account', $content); + } + + public function testRegisterAccountPageIsRendered() + { + $client = self::createClient(); + $this->request($client, '/register/'); + + $response = $client->getResponse(); + $this->assertTrue($response->isSuccessful()); + + $content = $response->getContent(); + $this->assertContains('Kimai - Time Tracking', $content); + $this->assertContains('Register a new account', $content); + $this->assertContains('', $content); + $this->assertContains('assertContains('id="fos_user_registration_form_email" name="fos_user_registration_form[email]" required="required" class="form-control"', $content); + $this->assertContains('assertContains('id="fos_user_registration_form_username" name="fos_user_registration_form[username]" required="required" maxlength="60" pattern=".{3,}" class="form-control"', $content); + $this->assertContains('assertContains('id="fos_user_registration_form_plainPassword_first" name="fos_user_registration_form[plainPassword][first]" required="required" autocomplete="new-password" class="form-control"', $content); + $this->assertContains('id="fos_user_registration_form_plainPassword_second" name="fos_user_registration_form[plainPassword][second]" required="required" autocomplete="new-password" class="form-control"', $content); + $this->assertContains('assertContains('id="fos_user_registration_form__token" name="fos_user_registration_form[_token]" class=" form-control"', $content); + $this->assertContains('>Register', $content); + } + + public function testRegisterAccount() + { + $client = self::createClient(); + $this->request($client, '/register/'); + + $response = $client->getResponse(); + $this->assertTrue($response->isSuccessful()); + + $form = $client->getCrawler()->filter('form[name=fos_user_registration_form]')->form(); + $client->submit($form, [ + 'fos_user_registration_form' => [ + 'email' => 'test@example.com', + 'username' => 'example', + 'plainPassword' => [ + 'first' => 'test123', + 'second' => 'test123', + ], + ] + ]); + + $this->assertIsRedirect($client, $this->createUrl('/register/confirmed')); + $client->followRedirect(); + $this->assertTrue($client->getResponse()->isSuccessful()); + + $content = $client->getResponse()->getContent(); + $this->assertContains('Kimai - Time Tracking', $content); + $this->assertContains('

Congrats example, your account is now activated.

', $content); + $this->assertContains('', $content); + } +}