@ignium I think this is an issue on your routes, can you share your route for route('home')?
Single test fails with BindingResolutionException after migrating to Laravel 8.x
I recently upgraded (with Laravel Shift) to Laravel 8.x and after tweaking a few of my tests, my entire test suite passes except for a single test with the following error:
There was 1 error:
- Tests\Feature\UserProfileVerificationFeatureTest::an_admin_profile_will_be_verified_once_edited Illuminate\Contracts\Container\BindingResolutionException: Target class [web] does not exist.
[stack trace removed for brevity]
Caused by ReflectionException: Class web does not exist
[stack trace removed for brevity]
Failing Test
/** @test */
public function an_admin_profile_will_be_verified_once_edited()
{
$admin = $this->signIn(['admin', 'profile_not_verified']);
// $admin = User::factory()->admin()->profileNotVerified()->create();
// $this->actingAs($admin);
$this->assertFalse($admin->profileIsVerified());
$unverified_text = __('app.Profile Not Verified');
$this->get(route('home')) //<=== FAILS HERE
->assertOk()
->assertSeeText($unverified_text);
Livewire::test(StaffAdminForm::class, ['staff' => $admin])
->call('submit')
->assertHasNoErrors()
->assertRedirect(route('staff.show', $admin))
->assertSessionHas('flash', $this->getSelfUpdateMessage());
$admin = $admin->refresh();
$this->assertTrue($admin->profileIsVerified());
$this->get(route('home'))
->assertOk()
->assertDontSeeText($unverified_text);
}
Passing Test (in same test class)
/** @test */
public function a_user_updating_their_unverified_profile_will_verify_it()
{
$user = $this->signIn('profile_not_verified');
$this->assertFalse($user->profileIsVerified());
$unverified_text = __('app.Profile Not Verified');
$this->get(route('home'))
->assertOk()
->assertSeeText($unverified_text);
Livewire::test(StaffForm::class, ['staff' => $user])
->call('submit')
->assertHasNoErrors()
->assertRedirect(route('staff.show', $user))
->assertSessionHas('flash', $this->getSelfUpdateMessage());
$user = $user->refresh();
$this->assertTrue($user->profileIsVerified());
$this->get(route('home'))
->assertOk()
->assertDontSeeText($unverified_text);
}
Any ideas why this is happening? The only difference is the parameters for the signIn() function, but I also tested passing an array to the passing test and it still passed, also in both cases the User is created successfully and the first $this->assertFalse($user->profileIsVerified() call passes without a problem. It's only when trying to visit the page that the BindingResolutionException is thrown.
Please or to participate in this conversation.