Mailgun
Mailgun copied to clipboard
Support mocking
Similar to faking Laravel's Mail, the Mailgun facade should be fakeable:
public function test_it_sends_email()
{
Mailgun::fake();
// any action that triggers sending mail through Bogardo/Mailgun package
$this->visit('/send-mail')
->press('Send!')
Mailgun::assertSent('mail.batch', function ($mail) use ($userA,$userB) {
return $mail->hasTo($userA->email, $userB->email) &&
$mail->hasCc('...') &&
$mail->isBcc('...') &&
$mail->isBcc('...');
});
}
At the moment I'm using Mailgun postbin to retrieve content and test against it, but is very slow. Would be amazing if it could support mocking. Despite the fact that mailgun allows test mode, it doesn't help testing the mail data.
@cosmini Couldn't you just mock the HTTP client? https://github.com/Bogardo/Mailgun#http-client-dependency
i've tried to do something similar to what's in the library test case: https://github.com/Bogardo/Mailgun/blob/master/tests/MailgunTestCase.php#L21
But I've got a whole new set of errors.
Perhaps it is possible to achieve this in other ways, but I'm using this library for convenience and to save time in development, having an easy way to test it would be a plus.
Thanks.