Mail test not passing

Posted 4 months ago by successdav

I am following up a laracast video on sending mails but my test is not passing...

My test class

use DatabaseMigrations;
    
    /** @test */
    public function a_comfirmation_email_is_sent_upon_registration()
    {
        Mail::fake();
        
        event(new Registered(create('App\User')));

        Mail::assertSent(PleaseConfirmYourEmail ::class);
    }

Event Service Provider Class

 protected $listen = [
        'App\Events\ThreadHasNewReply' => [
            'App\Listeners\NotifyThreadSubscribers',
        ],

        Registered::class => [
            'App\Listeners\SendEmailConfirmationRequest'
        ]
    ];

My SendEmailConfirmationRequest Class

   public function handle(Registered $event)
    {
        Mail::to($event->user)->send(new PleaseConfirmYourEmail());
    }

and when I run this test it just returns

1) Tests\Feature\RegistrationTest::a_comfirmation_email_is_sent_upon_registration
The expected [App\Mail\PleaseConfirmYourEmail] mailable was not sent.
Failed asserting that false is true.

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

Reply to

Use Markdown with GitHub-flavored code blocks.