How to use Mockery for a class used in a controller?

Posted 9 months ago by shadrix

Let's say my controller looks like that.

public function store()

And Newsletter is a Class to use MailChimps Api easier.

Now how do I write a test for it?

I tried this, but it does not work. (I'm new to Mockery and it sends the data to mailchimp).

use Spatie\Newsletter\Newsletter;
class NewsletterTest extends TestCase {

    use RefreshDatabase;

    public function setUp()


    public function tearDown() {

    /** @test */
    public function a_guest_can_subscribe_to_newsletter() 
        $this->json('post', route(''), ['email' => '[email protected]'])

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.