trashed()->createOne(); $response = $this->patch(route('api.video.restore', ['video' => $video])); $response->assertUnauthorized(); } /** * The Video Restore Endpoint shall forbid users without the restore video permission. * * @return void */ public function testForbidden(): void { $video = Video::factory()->trashed()->createOne(); $user = User::factory()->createOne(); Sanctum::actingAs($user); $response = $this->patch(route('api.video.restore', ['video' => $video])); $response->assertForbidden(); } /** * The Video Restore Endpoint shall forbid users from restoring a video that isn't trashed. * * @return void */ public function testTrashed(): void { $video = Video::factory()->createOne(); $user = User::factory()->withPermissions(ExtendedCrudPermission::RESTORE->format(Video::class))->createOne(); Sanctum::actingAs($user); $response = $this->patch(route('api.video.restore', ['video' => $video])); $response->assertForbidden(); } /** * The Video Restore Endpoint shall restore the video. * * @return void */ public function testRestored(): void { $video = Video::factory()->trashed()->createOne(); $user = User::factory()->withPermissions(ExtendedCrudPermission::RESTORE->format(Video::class))->createOne(); Sanctum::actingAs($user); $response = $this->patch(route('api.video.restore', ['video' => $video])); $response->assertOk(); static::assertNotSoftDeleted($video); } }