Oct 25, 2021
0
Level 2
Mockery From __Invoike
Hi everyone, I want to unit test controller with __invoke the function. Function:
/**
* @var Oauth2Responder
*/
private $responder;
private $action;
public function __construct(ShopResponder $responder, ShopAction $action)
{
$this->responder = $responder;
$this->action= $action;
}
public function __invoke(ShopRequest $request): JsonResponse
{
return $this->responder->handle($this->action->run($request->all()));
}
Test:
$callable = m::mock(ShopController::class);
$callable->allows()->__invoke(1)->andReturns(2)->getMock();
$this->assertTrue(true);
But this does not go to __invoke when I run coverage now. Please help me.
Please or to participate in this conversation.