Skip to content

[HELP] Test submitting a form that sends a message #546

Open
@abozhinov

Description

@abozhinov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions