Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Profiler re-reads mails between requests #9

Open
Jean85 opened this issue Nov 22, 2016 · 0 comments
Open

Profiler re-reads mails between requests #9

Jean85 opened this issue Nov 22, 2016 · 0 comments
Labels

Comments

@Jean85
Copy link
Member

Jean85 commented Nov 22, 2016

Case: a test on a controller that sends a mail, then redirects
Expected: if I count mail sent, I get 1
Bug: the mail is counted twice, once per client navigation, and I get 2

class ControllerTest extends ParaunitFunctionalTestCase
{
    public function testMail()
    {
        $client = static::getAuthorizedClient();
        $client->enableProfiler();
        $client->followRedirects();
        $crawler = $client->request('GET','notification/1');

        $button = $crawler->selectButton('notification[sendButton]');
        $form = $button->form();
        $client->submit($form);

        $mailCollector = $client->getProfile()->getCollector('swiftmailer');

        // Redirect followed!!
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
        // this fails!
        $this->assertEquals(1, $mailCollector->getMessageCount());
    }
}

For now, a possible workaround could be not following the redirect, checking the mail count before following the redirect o rebooting the kernel with the client. But this needs to be fixed.

@Jean85 Jean85 added the bug label Nov 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant