I am injecting the InvoiceService in the testclass. Test class calling the create method of the invoice service.. Constructor of the injected class not getting called because of this $repo is null create is failing. Any help is appreciated.
$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
}
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Sq7GOn
via IFTTT
Aucun commentaire:
Enregistrer un commentaire