Skip to content
This repository has been archived by the owner on Dec 22, 2019. It is now read-only.

Support mocking #114

Open
tpalts opened this issue May 3, 2017 · 3 comments
Open

Support mocking #114

tpalts opened this issue May 3, 2017 · 3 comments

Comments

@tpalts
Copy link

tpalts commented May 3, 2017

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('...');
        });
}
@cosmini
Copy link

cosmini commented Oct 16, 2019

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.

@Bogardo
Copy link
Owner

Bogardo commented Oct 16, 2019

@cosmini Couldn't you just mock the HTTP client?
https://github.com/Bogardo/Mailgun#http-client-dependency

@cosmini
Copy link

cosmini commented Oct 16, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants