I'm trying to write some tests using Pest and mocking my model. I have a Repository that accepts two models, this is the definition:
class MyRepo
{
public function __construct(private ModelA $modelA, private ModelB $modelB)
{
//
}
}
Now in my test i created two mock for ModelA
and ModelB
, and created the repository:
$modelA = mock(ModelA::class);
$modelB = mock(ModelB::class);
$repo = new MyRepo($modelA, $modelB);
Running this code I get a check error like this:
__construct(): Argument #1 ($modelA) must be of type App\Models\ModelA, Pest\Mock\Mock given
If I remove the type check on Repository constructor, all works fine.
I tried to find a solution, but for now, I have had no luck. I'm not able to understand what i need to change to make it works