From 9c793e6ecedfc24d1dbbc2303680844a8b8fb678 Mon Sep 17 00:00:00 2001 From: Camille Simiand <camille.simiand@tetras-libre.fr> Date: Tue, 14 Dec 2021 11:05:23 +0100 Subject: [PATCH] Add tests --- tests/functional/RegistrationControllerTest.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/functional/RegistrationControllerTest.php b/tests/functional/RegistrationControllerTest.php index 9cb13bb..a3cf7cc 100644 --- a/tests/functional/RegistrationControllerTest.php +++ b/tests/functional/RegistrationControllerTest.php @@ -18,7 +18,6 @@ class RegistrationControllerTest extends WebTestCase $this->registerUser($userEmail, $client); - $this->assertUserIsRedirectedToTheEmailNotificationPage($client); } @@ -101,6 +100,17 @@ class RegistrationControllerTest extends WebTestCase $this->assertResponseRedirects('/my_capsules', 302); } + public function testSubmittingTheRegisterFormWithAnInvalidEmailAddressShouldDisplayAFeedbackError(): void + { + $userEmail = 'invalidEmailAddress'; + $client = static::createClient(); + + $crawler = $this->registerUser($userEmail, $client); + $html = $crawler->outerHtml(); + + $this->assertStringContainsString("is not a valid email", $html); + } + /** * @param string $userEmail The registered user email * @return RawMessage The email message sent to the user @@ -136,7 +146,7 @@ class RegistrationControllerTest extends WebTestCase $this->assertResponseIsSuccessful('/register_mail_sent'); } - private function registerUser(string $userEmail, KernelBrowser &$client): void + private function registerUser(string $userEmail, KernelBrowser &$client): ?Crawler { $crawler = $client->request('GET', '/register'); @@ -147,7 +157,6 @@ class RegistrationControllerTest extends WebTestCase $submit = $crawler->selectButton('Register'); $form = $submit->form(); - $form['registration_form[firstName]'] = 'new User FirstName'; $form['registration_form[lastName]'] = 'new User LastName'; $form['registration_form[email]'] = $userEmail; @@ -155,7 +164,7 @@ class RegistrationControllerTest extends WebTestCase $form['registration_form[plainPassword][second]'] = 'password'; $form['registration_form[agreeTerms]'] = 1; - $client->submit($form); + return $client->submit($form); } private function clickOnEmailMessageLink(RawMessage $emailMessage, KernelBrowser $client): void -- GitLab