Your repository isn't resolving the dependency out of the IoC container.
public function __construct(){
$this->source = new \Oclify\Models\Dna\Source;
}
$this->source
is now equal to a brand new instance of Oclify\Models\Dna\Source
, at this point the repository has no idea about your mock because you haven't resolved the dependency, laravel does not hook into requests for a new instance of a class.
The instance
method on app
allows you bind an instance into the container, you'll need to then use the IoC container to retrieve that object, you could either use dependency resolution through the constructor, like so:
public function __construct(Oclify\Models\Dna\Source $source)
{
$this->source = $source;
}
or through make
:
public function __construct()
{
$this->source = App::make('Oclify\Models\Dna\Source');
}
hmm, okay thanks citric, imma try that
that sucks, okay so basically I have to do this?
App::bind("Oclify\Repos\Dna\SourceRepo",function(){
return new Oclify\Repos\Dna\SourceRepoEloquent(new Oclify\Models\Dna\Source);
});
along with the update to the __constructor method. This is the proper way to do it right? there was no other way?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community