panther
panther copied to clipboard
[HELP] Test submitting a form that sends a message
Hi, I have a Reset Password Request feature in my admin panel. I want to make an E2E test but can get the message. Use 'in-memory' transporter but it is always empty because the request is processed by the external web server. I want to fetch the message and read the URL.
public function testSendResetPasswordRequest(): void
{
$admin = $this->getAdmin();
$transport = self::getContainer()->get('messenger.transport.async');
$crawler = $this->client->request(Request::METHOD_GET, '/cms/admin/reset-password/request');
$form = $crawler->selectButton('Send')->form([
'username' => $admin->getUserIdentifier(),
]);
$this->client->waitForEnabled('button[type="submit"]');
$this->client->submit($form);
$this->assertSelectorWillContain('.noty_body', 'If there is an account with this email you will receive an email with a link to change the password.');
$this->assertCount(1, $transport->getSent());
}
I have a same problem..