New-ish to Laravel so pardon me if I'm getting something completely wrong.
I'm wanting to start unit testing my application and I'm running into a very peculiar error. The error I'm getting is:
PHPUnit_Framework_Exception: Fatal error: Uncaught exception 'Illuminate\Contracts\Container\BindingResolutionException' with message 'Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.' in C:\wamp\www\project_folder\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 744
If you need the full call stack I can provide that too.
As far as I'm understanding, the reason this is happening is because there's a binding error with the Illuminate\Contracts\Debug\ExceptionHandler
class. However I've done nothing (to my knowledge) to change the behaviour of the ExceptionHandler class nor the BindingResolutionException class.
This is only happening when there's an exception thrown in my unit tests. If the unit test does not throw an exception, then the unit tests run as expected with no errors or anything.
I've googled around for this error and I'm coming up dry. The closest thing I have found is this laravel issue (https://github.com/laravel/framework/issues/6322). I have tried the solutions by darkwinternight and GrahamCampbell but I haven't had any luck so far. Maybe I did something incorrect with their solutions, but I'm not sure.
Any help would be greatly appreciated, or just a nudge in the right direction.
Thanks.
Edit: I figure the code might be important as well, so here's my test that's throwing the error:
<?php
use App\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class UserControllerTest extends TestCase {
use DatabaseMigrations;
public function testCreateUserRoute() {
$user = User::where('id', 1)->firstOrFail();
$response = $this->actingAs($user)->call('POST', '/user/doCreateUser');
$this->assertEquals(200, $response->status());
}
}
I'm having the same problem. Apparently they changed a lot of things and left it out of the upgrade guide.
composer require "phpunit=~5"
seemed to be fixed. I almost had to make sure my /bootstrap/
folder was in sync with the laravel skeleton base app.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community