setUpHasPlanner(); } public function test_user_can_see_dish(): void { $planner = $this->planner; $dish = Dish::factory()->planner($planner)->create(); $this ->actingAs($planner) ->get(route('api.dishes.show', $dish)) ->assertStatus(200) ->assertJson(fn (AssertableJson $json) => $json ->where('success', true) ->has('payload', fn ($json) => $json ->has('dish', fn ($json) => $json ->where('id', $dish->id) ->where('planner_id', $planner->id) ->where('name', $dish->name) ->has('users') ) ) ->where('errors', null) ); } public function test_user_cannot_see_dish_from_other_user(): void { $planner = $this->planner; $otherPlanner = Planner::factory()->create(); $dish = Dish::factory()->planner($otherPlanner)->create(); $this ->actingAs($planner) ->get(route('api.dishes.show', $dish)) ->assertStatus(404); } }