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