Laravel unable to test job with mocked Service and object. The Mockery spy fails to detect called method

pcmagas

Dimitrios Desyllas

Posted on March 10, 2020

Laravel unable to test job with mocked Service and object. The Mockery spy fails to detect called method

Can you help me on this? I try to unit test a Laravel job.

I want to test my functionality of my Job:

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use App\Model\Model;
use App\Services\Service;

class MyJob implements ShouldQueue
{
    use Dispatchable;
    use InteractsWithQueue;
    use Queueable;

    /**
     * Undocumented variable
     *
     * @var User
     */
    private $model;

    public function __construct(Model $model)
    {
💖 💪 🙅 🚩
pcmagas
Dimitrios Desyllas

Posted on March 10, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related