Level 70
@karlhill69 can you be more explicit? Provide more context, what error you are getting?
Or provide your implementation if possible.
1 like
I have this test. it's failed. why?
/** @test */
public function it_sends_email_notification_to_provider()
{
// Fake the Mail facade
Mail::fake();
$this->withoutExceptionHandling();
$post = Post::factory()->published()
->create([
'emails' => '[email protected],[email protected]',
]);
// Dispatch the SendEmailNotificationToProvider job
SendEmailNotificationToProvider::dispatch($post);
// Assert that an email was sent to each provider
Mail::assertSent(PostPublishedInformProvider::class, function ($mail) use ($post) {
return $mail->assertTo('[email protected]');
});
// Optionally, you can check the number of times the email was sent
Mail::assertSent(PostPublishedInformProvider::class, 2);
}
@KarlHill69 If I understand you correctly, you are trying to send email to multiple users. Therefore your $mail->assertTo('provider1@example.com');.
I think you can fix your code like this way:
Mail::assertSent(PostPublishedInformProvider::class, function ($mail) use ($post) {
return in_array('[email protected]', array_column($mail->to, 'address'));
});
Please or to participate in this conversation.