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