Warning: Undefined variable $use_statements in /home/wordpri/www/cci/amar/Projet-v1 2 apache/vendor/symfony/maker-bundle/src/Resources/skeleton/registration/Test.WithVerify.tpl.php on line 4
class RegistrationControllerTest extends WebTestCase { private KernelBrowser $client; private
Warning: Undefined variable $repository_class_name in /home/wordpri/www/cci/amar/Projet-v1 2 apache/vendor/symfony/maker-bundle/src/Resources/skeleton/registration/Test.WithVerify.tpl.php on line 9
$userRepository; protected function setUp(): void { $this->client = static::createClient(); // Ensure we have a clean database $container = static::getContainer(); /** @var EntityManager $em */ $em = $container->get('doctrine')->getManager(); $this->userRepository = $container->get(
Warning: Undefined variable $repository_class_name in /home/wordpri/www/cci/amar/Projet-v1 2 apache/vendor/symfony/maker-bundle/src/Resources/skeleton/registration/Test.WithVerify.tpl.php on line 20
::class); foreach ($this->userRepository->findAll() as $user) { $em->remove($user); } $em->flush(); } public function testRegister(): void { // Register a new user $this->client->request('GET', '/register'); self::assertResponseIsSuccessful(); self::assertPageTitleContains('Register'); $this->client->submitForm('Register', [ 'registration_form[email]' => 'me@example.com', 'registration_form[plainPassword]' => 'password', 'registration_form[agreeTerms]' => true, ]); // Ensure the response redirects after submitting the form, the user exists, and is not verified // self::assertResponseRedirects('/'); @TODO: set the appropriate path that the user is redirected to. self::assertCount(1, $this->userRepository->findAll()); self::assertFalse(($user = $this->userRepository->findAll()[0])->isVerified()); // Ensure the verification email was sent // Use either assertQueuedEmailCount() || assertEmailCount() depending on your mailer setup // self::assertQueuedEmailCount(1); self::assertEmailCount(1); self::assertCount(1, $messages = $this->getMailerMessages()); self::assertEmailAddressContains($messages[0], 'from', '
Warning: Undefined variable $from_email in /home/wordpri/www/cci/amar/Projet-v1 2 apache/vendor/symfony/maker-bundle/src/Resources/skeleton/registration/Test.WithVerify.tpl.php on line 53
'); self::assertEmailAddressContains($messages[0], 'to', 'me@example.com'); self::assertEmailTextBodyContains($messages[0], 'This link will expire in 1 hour.'); // Login the new user $this->client->followRedirect(); $this->client->loginUser($user); // Get the verification link from the email /** @var TemplatedEmail $templatedEmail */ $templatedEmail = $messages[0]; $messageBody = $templatedEmail->getHtmlBody(); self::assertIsString($messageBody); preg_match('#(http://localhost/verify/email.+)">#', $messageBody, $resetLink); // "Click" the link and see if the user is verified $this->client->request('GET', $resetLink[1]); $this->client->followRedirect(); self::assertTrue(static::getContainer()->get(
Warning: Undefined variable $repository_class_name in /home/wordpri/www/cci/amar/Projet-v1 2 apache/vendor/symfony/maker-bundle/src/Resources/skeleton/registration/Test.WithVerify.tpl.php on line 73
::class)->findAll()[0]->isVerified()); } }