DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

Why console application fails to retrieve mocked service during testing?

I have issues changing the service provided by laravel to the console.

I have the following console application:

namespace App\Console\Commands
use Illuminate\Console\Command;
use App\Services\Myservice;

class MyCommand extends Command
{
    protected $signature = 'test';
    
    public function handle(Myservice $service){
       dump($service->dummy());
    }
}

And I have the following service:

namespace App\Services;

class Myservice
{
   public function dummy()
   {
      return false;
   }
}

I also made…

Top comments (0)