DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

Why I am unable to assert that an email has been sent from a laravel job?

I am trying to assert that an email has been sent from a job that dispatches another job. Though I am unable to assert that an email has been sent.

In laravel I need tot est the following job:

namespace App\Jobs
use App\Jobs\AnotharJob;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class AJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function handle()
    {
      //Some logic here

      AnotharJob::dispatch();
    }
}

In laravel I need tot est the…

Do you know why?

Top comments (1)

Collapse
 
gkoniaris profile image
George Koniaris

Not sure about this, but try to set the email subject in your Mailable to 'Hello' and provide the new results. I think that the test tries to validate that the email was sent AND that the subject of the email was set to 'Hello'.