create(['name' => 'Report A']); // When loading reports/custom while acting as another user that also has a saved template $user = User::factory()->canViewReports() ->has(ReportTemplate::factory(['name' => 'Report B'])) ->create(); // The user should not see the other user's template (in view as 'report_templates') $this->actingAs($user) ->get(route('reports/custom')) ->assertViewHas(['report_templates' => function (Collection $reports) { return $reports->pluck('name')->doesntContain('Report A'); }]); } }