panther icon indicating copy to clipboard operation
panther copied to clipboard

[HELP] Test submitting a form that sends a message

Open abozhinov opened this issue 2 years ago • 2 comments

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());
    }

abozhinov avatar May 03 '22 14:05 abozhinov

I have a same problem..

norkunas avatar May 17 '22 14:05 norkunas