You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wouldn't be better to test getting the phrase from the session in the container? This way the integration of the captcha with your forms could be tested too.
This is how I do it in a contact form:
$crawler = $client->request(Request::METHOD_GET, '/contact');
self::assertStatusCodeEquals(Response::HTTP_OK, $client);
$session = static::$kernel->getContainer()->get('session');
$captcha = $session->get('_captcha_captcha');
$form = $crawler->selectButton(self::SEND_MESSAGE_LABEL)->form();
$form->get('contact_request[name]')->setValue('John Smith');
$form->get('contact_request[email]')->setValue('[email protected]');
$form->get('contact_request[subject]')->setValue('A test email');
$form->get('contact_request[body]')->setValue('This email is sent from a test');
$form->get('contact_request[captcha]')->setValue($captcha['phrase']);
$client->submit($form);
Hi,
I am running PhpUnit test but I do not know how to set the captcha value in the form before submitting the form?
May I can read the Symfony session but later the session will no longer valid/stored.
Any idea?
The text was updated successfully, but these errors were encountered: