planner; $newUserName = fake()->name; $user = User::factory()->planner($planner)->create(); $this ->actingAs($planner) ->put(route('api.users.update', $user), [ 'name' => $newUserName, ]) ->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', $newUserName) ) ) ->where('errors', null) ); } public function test_planner_cannot_update_user_of_other_planner(): void { $planner = $this->planner; $otherPlanner = Planner::factory()->create(); $newUserName = fake()->name; $user = User::factory()->planner($otherPlanner)->create(); $this ->actingAs($planner) ->put(route('api.users.update', $user), [ 'name' => $newUserName, ]) ->assertStatus(404) ->assertJson(fn (AssertableJson $json) => $json ->where('success', false) ->where('payload', null) ->where('errors', ["MODEL_NOT_FOUND"]) ); } }