Description
- Laravel Version: 5.4.19
- PHP Version: 7.1.4
- Database Driver & Version: mysql
- Was introduced by pull request [5.4] Set connection while retrieving models #18769 i guess
Description:
When I upgraded from laravel/framework 5.4.18 to 5.4.19 some of my unit tests broke. This is because somehow the models i get when making http requests (via the BrowserKitTest features) now have a connection provided, while the user i create via a factory and then use within the application via $this->actingAs have null as db connection. This leads to false returns when doing checks via $user->is($modelFromRouteModelBinding->user);
Steps To Reproduce:
Use $this->actingAs($userFromFactory) in BrowserKitTests and then call some of your routes via $this->json('GET', '/test') or so. When you use checks i.e. for security like $userFromRequest->is($modelFromRouteModelBinding->user), you will get false because the connections differ (null vs the (now) correct connection).