planner; $user = User::factory()->planner($planner)->create(); $this ->actingAs($planner) ->get(route('api.users.show', ['user' => $user])) ->assertStatus(200) ->assertJson(fn (AssertableJson $json) => $json ->where('success', true) ->has('payload', fn ($json) => $json ->has('user', fn ($json) => $json ->where('id', $user->id) ->where('name', $user->name) ) ) ->where('errors', null) ); } public function test_planner_cannot_see_user_from_other_planner(): void { $planner = $this->planner; $otherPlanner = Planner::factory()->create(); $user = User::factory()->planner($otherPlanner)->create(); $this ->actingAs($planner) ->get(route('api.users.show', ['user' => $user])) ->assertStatus(404) ->assertJson(fn (AssertableJson $json) => $json ->where('success', false) ->where('payload', null) ->where('errors', ['MODEL_NOT_FOUND']) ); } }