Laravel Testing Service Dependency Injection Error Laravel Testing Service Dependency Injection Error laravel laravel

Laravel Testing Service Dependency Injection Error


You cannot inject classes into the tests (as far as i know), given that they are not resolved automatically by laravel/phpUnit.

The correct way is to make (resolve) them through laravel's app facade. Your test script should look like this:

<?phpclass SomeValidatorTest extends TestCase{    public function __construct()    {        $this->validator = \App::make('App\Services\Validators\SomeValidator');    }    public function testBasicExample()    {        $result = $this->validator->doSomething();    }}

Source: http://laravel.com/docs/5.1/container