Assert against any email in the mailbox
polevaultweb opened this issue · 2 comments
polevaultweb commented
@foxted what do you think about enhancing the 'see' assertions so we can look in X last emails.
My use case is testing a process that sends 2 emails at the same time, but at the moment I can only see the last message to run assertions against.
So instead of:
public function seeInEmailHtmlBody($expected)
{
$email = $this->fetchLastMessage();
$this->assertContains($expected, $email['html_body'], 'Email body contains HTML');
}
We do
public function seeInEmailHtmlBody($expected, $numberOfMessages = 1)
{
$email = $this->fetchLastMessages(numberOfMessages);
$this->assertContains($expected, $email['html_body'], 'Email body contains HTML');
}
This way the default is still the last message but we can look in a range of mails to assert one exists based on certain criteria.
polevaultweb commented
@foxted happy to raise a PR 😄
foxted commented
Seem like a valid use case, sure! :)