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