diff --git a/src/Api/Serializer/ExportSerializer.php b/src/Api/Serializer/ExportSerializer.php index d746b3b..9f446d9 100644 --- a/src/Api/Serializer/ExportSerializer.php +++ b/src/Api/Serializer/ExportSerializer.php @@ -37,12 +37,12 @@ protected function getDefaultAttributes($export) return $attributes; } - protected function user($export): Relationship + protected function user($export): ?Relationship { return $this->hasOne($export, BasicUserSerializer::class); } - protected function actor($export): Relationship + protected function actor($export): ?Relationship { return $this->hasOne($export, BasicUserSerializer::class); } diff --git a/src/Api/Serializer/RequestErasureSerializer.php b/src/Api/Serializer/RequestErasureSerializer.php index 36103bb..616e1ed 100644 --- a/src/Api/Serializer/RequestErasureSerializer.php +++ b/src/Api/Serializer/RequestErasureSerializer.php @@ -36,12 +36,12 @@ protected function getDefaultAttributes($erasure_request) ]; } - protected function user($erasure_request): Relationship + protected function user($erasure_request): ?Relationship { return $this->hasOne($erasure_request, BasicUserSerializer::class); } - protected function processedBy($erasure_request): Relationship + protected function processedBy($erasure_request): ?Relationship { return $this->hasOne($erasure_request, BasicUserSerializer::class); } diff --git a/src/Http/Controller/ExportController.php b/src/Http/Controller/ExportController.php index 26389e8..9c16b9b 100644 --- a/src/Http/Controller/ExportController.php +++ b/src/Http/Controller/ExportController.php @@ -36,7 +36,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface 200, [ 'Content-Type' => 'application/zip', - 'Content-Length' => $this->storageManager->getStoredExportSize($export), + 'Content-Length' => (string) $this->storageManager->getStoredExportSize($export), 'Content-Disposition' => 'attachment; filename="data-export-'.$export->user->username.'-'.$export->created_at->toIso8601String().'.zip"', ] ); diff --git a/tests/integration/api/ProcessErasureTest.php b/tests/integration/api/ProcessErasureTest.php index 4971e73..4c0665a 100644 --- a/tests/integration/api/ProcessErasureTest.php +++ b/tests/integration/api/ProcessErasureTest.php @@ -85,6 +85,28 @@ public function authorized_users_can_see_confirmed_erasure_requests() $this->assertEquals(ErasureRequest::STATUS_USER_CONFIRMED, $json['data'][0]['attributes']['status']); } + /** + * @test + */ + public function authorized_users_can_see_confirmed_erasure_requests_even_if_user_was_deleted() + { + $this->send($this->request('GET', '/api/forum')); + User::query()->where('id', 5)->delete(); + + $response = $this->send( + $this->request('GET', '/api/user-erasure-requests', [ + 'authenticatedAs' => 3, + ]) + ); + + $this->assertEquals(200, $response->getStatusCode()); + + $json = json_decode($response->getBody()->getContents(), true); + + $this->assertCount(1, $json['data']); + $this->assertEquals(ErasureRequest::STATUS_USER_CONFIRMED, $json['data'][0]['attributes']['status']); + } + /** * @test */