Я внедряю InvoiceService в тестовый класс. Тестовый класс, вызывающий метод create службы invoice. Конструктор внедренного класса не вызывается из-за этого $ repo is null create не работает. Любая помощь приветствуется.
$this->app->singleton(
'App\Models\Subscription\Interfaces\IInvoiceService',
'App\Models\Subscription\Impl\InvoiceService'
);
class InvoiceService implements IInvoiceService
{
protected $repo;
public function _construct(){
$this->app = App::getFacadeRoot();
$this->repo = $this->app['repo'];
}
public function Create($array)
{
$this->repo->insert($array); // //$this->repo is null as Constructor not getting called
}
}
class TestClass
{
protected $InvoiceService;
public function _construct(IInvoiceService $InvoiceService){
$this->InvoiceService =$InvoiceService
}
public create($input) {
this->InvoiceService->create($input); // This is failing
}
}