Have you run the queue worker on your server ?
https://laravel.com/docs/10.x/queues#running-the-queue-worker
Summer Sale! All accounts are 50% off this week.
I my unit test I try to test the notification should queued on "email" queue.
This is my test code:
/** @test */
public function shouldQueueMail(): void
{
Queue::fake();
// ... prepare datas
$notification = new FormFilledNotification($to, $subject, $formData);
$notifiable = new Form();
$formMail = $notification->toMail($notifiable);
Notification::send($notifiable, $notification);
Queue::assertPushed(FormMail::class);
}
And I get this error:
ReflectionException: Method ...\FormMail::__invoke() does not exist
That is actually true, but I don't understand why I get this message.
I tried to use Queue::spy() and it say:
RuntimeException: Queue resolver did not return a Queue implementation.
The FormMail looks like this:
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Spatie\MailTemplates\Interfaces\MailTemplateInterface;
use Spatie\MailTemplates\TemplateMailable;
class FormMail extends TemplateMailable implements Mailable
{
use Queueable;
use SerializesModels;
protected static $templateModelClass = EmailTemplate::class;
public $details = '';
public Form $form;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(array $form_data, Form $form)
{
$this->form = $form;
$this->details = (new FormDetailsMailComponent($form_data))
->render();
}
protected function resolveTemplateModel(): MailTemplateInterface
{
return $this->mailTemplate = $this->form->emailTemplate()->first()
?? EmailTemplate::whereCode(EmailTemplateCodesEnum::FORM_SENT)->first();
}
}
So what I miss to run after Notification::send()?
Please or to participate in this conversation.