Antonella's avatar

how to test a custom command in TDD?

how can i test a command i have created with a feature test?

i created this command: pruneTask

    protected $signature = 'prune:task {x} {y} ';

public function handle()
{
    $x = $this->argument('x');
    $y = $this->argument('y');
    Task::where('instance',$x)->where('job',$y)->delete();
}

the command does what it has to do I was wondering how to test it with feature Test?

like how could I make the mock?

0 likes
3 replies
Antonella's avatar

yes ok but these are high level tests, I wanted to try to understand how to make the mock to do the test @martinbean

martinbean's avatar

@gianmarx What are you trying to mock? If you’re testing an Artisan command, then you test that, given some input, it performs some actions.

Please or to participate in this conversation.