*/ private array $macros = []; public function __construct(Environment $env) { parent::__construct($env); $this->source = $this->getSourceContext(); $this->parent = false; $this->blocks = [ ]; } protected function doDisplay(array $context, array $blocks = []): iterable { $macros = $this->macros; $__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"]; $__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "@Maker/security/formLogin/Test.LoginController.tpl.php")); $__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"]; $__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "@Maker/security/formLogin/Test.LoginController.tpl.php")); // line 1 yield " namespace App\\Tests; class LoginControllerTest extends WebTestCase { private KernelBrowser \$client; protected function setUp(): void { \$this->client = static::createClient(); \$container = static::getContainer(); \$em = \$container->get('doctrine.orm.entity_manager'); \$userRepository = \$em->getRepository(::class); // Remove any existing users from the test database foreach (\$userRepository->findAll() as \$user) { \$em->remove(\$user); } \$em->flush(); // Create a fixture /** @var UserPasswordHasherInterface \$passwordHasher */ \$passwordHasher = \$container->get('security.user_password_hasher'); \$user = (new ())->setEmail('email@example.com'); \$user->setPassword(\$passwordHasher->hashPassword(\$user, 'password')); \$em->persist(\$user); \$em->flush(); } public function testLogin(): void { // Denied - Can't login with invalid email address. \$this->client->request('GET', '/login'); self::assertResponseIsSuccessful(); \$this->client->submitForm('Sign in', [ '_username' => 'doesNotExist@example.com', '_password' => 'password', ]); self::assertResponseRedirects('/login'); \$this->client->followRedirect(); // Ensure we do not reveal if the user exists or not. self::assertSelectorTextContains('.alert-danger', 'Invalid credentials.'); // Denied - Can't login with invalid password. \$this->client->request('GET', '/login'); self::assertResponseIsSuccessful(); \$this->client->submitForm('Sign in', [ '_username' => 'email@example.com', '_password' => 'bad-password', ]); self::assertResponseRedirects('/login'); \$this->client->followRedirect(); // Ensure we do not reveal the user exists but the password is wrong. self::assertSelectorTextContains('.alert-danger', 'Invalid credentials.'); // Success - Login with valid credentials is allowed. \$this->client->submitForm('Sign in', [ '_username' => 'email@example.com', '_password' => 'password', ]); self::assertResponseRedirects('/'); \$this->client->followRedirect(); self::assertSelectorNotExists('.alert-danger'); self::assertResponseIsSuccessful(); } } "; $__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof); $__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof); yield from []; } /** * @codeCoverageIgnore */ public function getTemplateName(): string { return "@Maker/security/formLogin/Test.LoginController.tpl.php"; } /** * @codeCoverageIgnore */ public function getDebugInfo(): array { return array ( 48 => 1,); } public function getSourceContext(): Source { return new Source(" namespace App\\Tests; class LoginControllerTest extends WebTestCase { private KernelBrowser \$client; protected function setUp(): void { \$this->client = static::createClient(); \$container = static::getContainer(); \$em = \$container->get('doctrine.orm.entity_manager'); \$userRepository = \$em->getRepository(::class); // Remove any existing users from the test database foreach (\$userRepository->findAll() as \$user) { \$em->remove(\$user); } \$em->flush(); // Create a fixture /** @var UserPasswordHasherInterface \$passwordHasher */ \$passwordHasher = \$container->get('security.user_password_hasher'); \$user = (new ())->setEmail('email@example.com'); \$user->setPassword(\$passwordHasher->hashPassword(\$user, 'password')); \$em->persist(\$user); \$em->flush(); } public function testLogin(): void { // Denied - Can't login with invalid email address. \$this->client->request('GET', '/login'); self::assertResponseIsSuccessful(); \$this->client->submitForm('Sign in', [ '_username' => 'doesNotExist@example.com', '_password' => 'password', ]); self::assertResponseRedirects('/login'); \$this->client->followRedirect(); // Ensure we do not reveal if the user exists or not. self::assertSelectorTextContains('.alert-danger', 'Invalid credentials.'); // Denied - Can't login with invalid password. \$this->client->request('GET', '/login'); self::assertResponseIsSuccessful(); \$this->client->submitForm('Sign in', [ '_username' => 'email@example.com', '_password' => 'bad-password', ]); self::assertResponseRedirects('/login'); \$this->client->followRedirect(); // Ensure we do not reveal the user exists but the password is wrong. self::assertSelectorTextContains('.alert-danger', 'Invalid credentials.'); // Success - Login with valid credentials is allowed. \$this->client->submitForm('Sign in', [ '_username' => 'email@example.com', '_password' => 'password', ]); self::assertResponseRedirects('/'); \$this->client->followRedirect(); self::assertSelectorNotExists('.alert-danger'); self::assertResponseIsSuccessful(); } } ", "@Maker/security/formLogin/Test.LoginController.tpl.php", "/var/www/cds-intranet/app/vendor/symfony/maker-bundle/templates/security/formLogin/Test.LoginController.tpl.php"); } }