I'm quite new about testing. I'm wondering what is the best way to make my classe testable. Is it better to do :
class SomeClass {
protected $dependency;
public function __construct(Dependency $dependency)
{
$this->dependency = $dependency;
}
...
Or use the laravel Ioc Container :
class SomeClass {
protected $dependency;
public function __construct($app)
{
$this->dependency = $app->make('dependency');
}
...
What do you think ?
If you can mock all your dependencies you'll be fine.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community