create(); $this->actingAsForApi(User::factory()->create()) ->patchJson(route('api.departments.update', $department)) ->assertForbidden(); } public function testCanUpdateDepartmentViaPatch() { $department = Department::factory()->create(); $this->actingAsForApi(User::factory()->superuser()->create()) ->patchJson(route('api.departments.update', $department), [ 'name' => 'Test Department', ]) ->assertOk() ->assertStatusMessageIs('success') ->assertStatus(200) ->json(); $department->refresh(); $this->assertEquals('Test Department', $department->name, 'Name was not updated'); } }