Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No obvious way to fake / test Newsletter #271

Closed
danielsetreus opened this issue Dec 6, 2021 · 3 comments
Closed

No obvious way to fake / test Newsletter #271

danielsetreus opened this issue Dec 6, 2021 · 3 comments

Comments

@danielsetreus
Copy link

Let's say I have a service that among other things does

Newsletter::addTags(...)

How would I go about writing tests for that service? I can't find any obvious way of faking the facade, and it seems there are no methods for asserting the actions it does towards Mailchimp.

@spatie-bot
Copy link

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.

@clementmas
Copy link

I'm also looking for a way to test that a user was subscribed to a list. Is that possible?
I don't see any Newsletter::fake() method available.

At the moment I have to ignore that call by adding this to phpunit.xml:

<env name="MAILCHIMP_DRIVER" value="null"/>

@javierpomachagua
Copy link

@clementmas
You can use the method 'shouldReceive' from the Facade.

Newsletter::shouldReceive('isSubscribed')
        ->with($subscriber->email)
        ->once()
        ->andReturn(false);

    Newsletter::shouldReceive('subscribe')
        ->with($subscriber->email)
        ->once()
        ->andReturnNull();

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

No branches or pull requests

4 participants