diff --git a/README.md b/README.md index 5cda690..93225e1 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ then optimize the processes that power the core of your business. | Documents/AnnotationsStamps | Get Stamps | ❌ | | Documents/DocumentsTrashBin | Get Documents | ✅ | | Documents/DocumentsTrashBin | Delete Documents | ✅ | -| Documents/DocumentsTrashBin | Restore Documents | ❌ | +| Documents/DocumentsTrashBin | Restore Documents | ✅ | | Documents/ApplicationProperties | Get Application Properties | ❌ | | Documents/ApplicationProperties | Add Application Properties | ❌ | | Documents/ApplicationProperties | Delete Application Properties | ❌ | diff --git a/src/DTO/Documents/DocumentsTrashBin/RestoreDocuments.php b/src/DTO/Documents/DocumentsTrashBin/RestoreDocuments.php new file mode 100644 index 0000000..476996e --- /dev/null +++ b/src/DTO/Documents/DocumentsTrashBin/RestoreDocuments.php @@ -0,0 +1,25 @@ + $this->ids instanceof Collection ? $this->ids->toArray() : $this->ids, + ]; + } + + public function createDtoFromResponse(Response $response): RestoreDocumentsDto + { + return RestoreDocumentsResponse::fromResponse($response); + } +} diff --git a/src/Responses/Documents/DocumentsTrashBin/RestoreDocumentsResponse.php b/src/Responses/Documents/DocumentsTrashBin/RestoreDocumentsResponse.php new file mode 100644 index 0000000..bce1134 --- /dev/null +++ b/src/Responses/Documents/DocumentsTrashBin/RestoreDocumentsResponse.php @@ -0,0 +1,20 @@ +throw()->json()); + } +} diff --git a/tests/Feature/Requests/Documents/DocumentsTrashBin/DeleteDocumentsFromTrashBinTest.php b/tests/Feature/Requests/Documents/DocumentsTrashBin/DeleteDocumentsFromTrashBinTest.php index cc8b712..86ddd56 100644 --- a/tests/Feature/Requests/Documents/DocumentsTrashBin/DeleteDocumentsFromTrashBinTest.php +++ b/tests/Feature/Requests/Documents/DocumentsTrashBin/DeleteDocumentsFromTrashBinTest.php @@ -6,7 +6,7 @@ use CodebarAg\DocuWare\Requests\FileCabinets\Upload\CreateDataRecord; use Illuminate\Support\Facades\Event; -it('can search documents in trash', function () { +it('can delete documents in trash', function () { Event::fake(); $document = $this->connector->send(new CreateDataRecord( diff --git a/tests/Feature/Requests/Documents/DocumentsTrashBin/RestoreDocumentsFromTrashBinTest.php b/tests/Feature/Requests/Documents/DocumentsTrashBin/RestoreDocumentsFromTrashBinTest.php new file mode 100644 index 0000000..0b39b03 --- /dev/null +++ b/tests/Feature/Requests/Documents/DocumentsTrashBin/RestoreDocumentsFromTrashBinTest.php @@ -0,0 +1,33 @@ +connector->send(new CreateDataRecord( + config('laravel-docuware.tests.file_cabinet_id'), + file_get_contents(__DIR__.'/../../../../Fixtures/files/test-1.pdf'), + 'test-1.pdf', + ))->dto(); + + $this->connector->send(new DeleteDocument( + config('laravel-docuware.tests.file_cabinet_id'), + $document->id, + ))->dto(); + + $paginatorRequest = (new DocuWare()) + ->searchRequestBuilder() + ->trashBin() + ->get(); + + $paginator = $this->connector->send($paginatorRequest)->dto(); + + $delete = $this->connector->send(new RestoreDocuments($paginator->mappedDocuments->pluck('ID')->all()))->dto(); + + expect($delete->successCount)->toBe($paginator->total); +})->group('restore', 'trash'); diff --git a/tests/Feature/SleepTest.php b/tests/Feature/SleepTest.php index ff22466..fba0ba4 100644 --- a/tests/Feature/SleepTest.php +++ b/tests/Feature/SleepTest.php @@ -8,4 +8,5 @@ Sleep::for(5)->seconds(); Log::info(now()->toDateTimeString()); -})->expectNotToPerformAssertions(); +})->expectNotToPerformAssertions() + ->skip('Testing sleep function.'); diff --git a/tests/Pest.php b/tests/Pest.php index 1905e7b..3662772 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -42,17 +42,17 @@ function clearFiles(): void ))->dto(); } - // $paginatorRequest = (new DocuWare()) - // ->searchRequestBuilder() - // ->trashBin() - // ->perPage(1000) - // ->get(); - // - // $paginator = $connector->send($paginatorRequest)->dto(); - // - // if ($paginator->total > 0) { - // $connector->send(new DeleteDocuments($paginator->mappedDocuments->pluck('ID')->all()))->dto(); - // } + $paginatorRequest = (new DocuWare()) + ->searchRequestBuilder() + ->trashBin() + ->perPage(1000) + ->get(); + + $paginator = $connector->send($paginatorRequest)->dto(); + + if ($paginator->total > 0) { + $connector->send(new DeleteDocuments($paginator->mappedDocuments->pluck('ID')->all()))->dto(); + } } function setUsersInactive(): void