createOne(); $response = $this->delete(route('api.anime.destroy', ['anime' => $anime])); $response->assertUnauthorized(); } /** * The Anime Destroy Endpoint shall forbid users without the delete anime permission. * * @return void */ public function testForbidden(): void { $anime = Anime::factory()->createOne(); $user = User::factory()->createOne(); Sanctum::actingAs($user); $response = $this->delete(route('api.anime.destroy', ['anime' => $anime])); $response->assertForbidden(); } /** * The Anime Destroy Endpoint shall forbid users from updating an anime that is trashed. * * @return void */ public function testTrashed(): void { $anime = Anime::factory()->trashed()->createOne(); $user = User::factory()->withPermissions(CrudPermission::DELETE->format(Anime::class))->createOne(); Sanctum::actingAs($user); $response = $this->delete(route('api.anime.destroy', ['anime' => $anime])); $response->assertNotFound(); } /** * The Anime Destroy Endpoint shall delete the anime. * * @return void */ public function testDeleted(): void { $anime = Anime::factory()->createOne(); $user = User::factory()->withPermissions(CrudPermission::DELETE->format(Anime::class))->createOne(); Sanctum::actingAs($user); $response = $this->delete(route('api.anime.destroy', ['anime' => $anime])); $response->assertOk(); static::assertSoftDeleted($anime); } }