#How to Mock DI?

4 messages · Page 1 of 1 (latest)

final gate
#

When in Repository A the code looks like this:

class ARepository extends Repository implements IARepository
{
    public function __construct(User $model, protected IBRepository $bRepository)
    {
        parent::__construct($model);
    }

    public function delete(int $id, int $bId = null): void
    {
        User::query()->whereKey($id)->delete();
        $this->bRepository->delete($bId);
    }
}
#

However spying that interface and doing the same shouldReceived doesnt work. Any suggestions?

steel hearth
#

Which implementation is the interface bound to?

final gate
#

What do you mean exactly?