Solution:
You can mock the repository class and load it into the IoC container.
So when Laravel gets to your controller, it will find it already in there and will resolve your mock instead of instantiating a new one.
function test_it_shows_a_single_widget()
{
// mock the repository
$repository = Mockery::mock(WidgetRepository::class);
$repository->shouldReceive('find')
->with(1)
->once()
->andReturn(new Widget([]));
// load the mock into the IoC container
$this->app->instance(WidgetRepository::class, $repository);
// when making your call, your controller will use your mock
$response = $this->action('GET', 'WidgetsController@show', ['id' => 1]);
// continue with assertions
// ...
}
A similar setup has been tested and working fine in Laravel 5.3.21.