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