From f388f1aa6753ba27d5607978940f704531f91bc5 Mon Sep 17 00:00:00 2001 From: Rhys Lees <43909932+RhysLees@users.noreply.github.com> Date: Fri, 13 Oct 2023 12:15:08 +0100 Subject: [PATCH] Dto checks --- tests/Feature/Requests/Dialogs/GetDialogsRequestTest.php | 7 +++++++ .../Requests/Document/GetDocumentCountRequestTest.php | 4 ++++ tests/Feature/Requests/Document/GetDocumentRequestTest.php | 1 + .../Feature/Requests/Document/GetDocumentsRequestTest.php | 1 + .../Feature/Requests/Document/PostDocumentRequestTest.php | 1 + .../Requests/Document/PutDocumentFieldsRequestTest.php | 3 +++ .../Thumbnail/GetDocumentDownloadThumbnailRequestTest.php | 4 ++++ tests/Feature/Requests/Fields/GetFieldsRequestTest.php | 7 +++++++ .../Requests/FileCabinets/GetFileCabinetsRequestTest.php | 6 ++++++ .../Requests/Organization/GetOrganizationsRequestTest.php | 6 ++++++ 10 files changed, 40 insertions(+) diff --git a/tests/Feature/Requests/Dialogs/GetDialogsRequestTest.php b/tests/Feature/Requests/Dialogs/GetDialogsRequestTest.php index dbf10bc6..f070a6b5 100644 --- a/tests/Feature/Requests/Dialogs/GetDialogsRequestTest.php +++ b/tests/Feature/Requests/Dialogs/GetDialogsRequestTest.php @@ -2,6 +2,7 @@ use CodebarAg\DocuWare\Connectors\DocuWareStaticConnector; use CodebarAg\DocuWare\DTO\Config; +use CodebarAg\DocuWare\DTO\Dialog; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Requests\Dialogs\GetDialogsRequest; use CodebarAg\DocuWare\Support\EnsureValidCookie; @@ -32,6 +33,12 @@ $dialogs = $this->connector->send(new GetDialogsRequest($fileCabinetId))->dto(); $this->assertInstanceOf(Collection::class, $dialogs); + $this->assertNotCount(0, $dialogs); + + foreach ($dialogs as $dialog) { + $this->assertInstanceOf(Dialog::class, $dialog); + } + Event::assertDispatched(DocuWareResponseLog::class); }); diff --git a/tests/Feature/Requests/Document/GetDocumentCountRequestTest.php b/tests/Feature/Requests/Document/GetDocumentCountRequestTest.php index f482e09f..f1147f7f 100644 --- a/tests/Feature/Requests/Document/GetDocumentCountRequestTest.php +++ b/tests/Feature/Requests/Document/GetDocumentCountRequestTest.php @@ -42,7 +42,11 @@ $dialogId ))->dto(); + + $this->assertIsInt($count); + $this->assertSame(1, $count); + Event::assertDispatched(DocuWareResponseLog::class); $this->connector->send(new DeleteDocumentRequest( diff --git a/tests/Feature/Requests/Document/GetDocumentRequestTest.php b/tests/Feature/Requests/Document/GetDocumentRequestTest.php index b8875d5f..bfb56c52 100644 --- a/tests/Feature/Requests/Document/GetDocumentRequestTest.php +++ b/tests/Feature/Requests/Document/GetDocumentRequestTest.php @@ -40,6 +40,7 @@ $getdocument = $this->connector->send(new GetDocumentRequest($fileCabinetId, $document->id))->dto(); $this->assertInstanceOf(Document::class, $getdocument); + $this->assertSame($document->id, $getdocument->id); $this->assertSame($fileCabinetId, $getdocument->file_cabinet_id); Event::assertDispatched(DocuWareResponseLog::class); diff --git a/tests/Feature/Requests/Document/GetDocumentsRequestTest.php b/tests/Feature/Requests/Document/GetDocumentsRequestTest.php index 03a3da70..6f66af44 100644 --- a/tests/Feature/Requests/Document/GetDocumentsRequestTest.php +++ b/tests/Feature/Requests/Document/GetDocumentsRequestTest.php @@ -46,6 +46,7 @@ foreach ($documents as $document) { $this->assertInstanceOf(Document::class, $document); + $this->connector->send(new DeleteDocumentRequest( config('docuware.tests.file_cabinet_id'), $document->id, diff --git a/tests/Feature/Requests/Document/PostDocumentRequestTest.php b/tests/Feature/Requests/Document/PostDocumentRequestTest.php index be6ea860..dfc5d182 100644 --- a/tests/Feature/Requests/Document/PostDocumentRequestTest.php +++ b/tests/Feature/Requests/Document/PostDocumentRequestTest.php @@ -49,6 +49,7 @@ ))->dto(); $this->assertInstanceOf(Document::class, $document); + $this->assertSame('example', $document->title); tap($document->fields['DOCUMENT_LABEL'], function (DocumentField $field) { $this->assertSame($field->name, 'DOCUMENT_LABEL'); diff --git a/tests/Feature/Requests/Document/PutDocumentFieldsRequestTest.php b/tests/Feature/Requests/Document/PutDocumentFieldsRequestTest.php index 2e1afe3d..784d6585 100644 --- a/tests/Feature/Requests/Document/PutDocumentFieldsRequestTest.php +++ b/tests/Feature/Requests/Document/PutDocumentFieldsRequestTest.php @@ -7,6 +7,7 @@ use CodebarAg\DocuWare\Requests\Document\PostDocumentRequest; use CodebarAg\DocuWare\Requests\Document\PutDocumentFieldsRequest; use CodebarAg\DocuWare\Support\EnsureValidCookie; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\Event; uses()->group('docuware'); @@ -74,6 +75,8 @@ true ))->dto(); + $this->assertInstanceOf(Collection::class, $response); + $this->assertSame('laravel-docuware', $response['UUID']); $this->assertSame('laravel-docuware-2', $response['DOCUMENT_LABEL']); diff --git a/tests/Feature/Requests/Document/Thumbnail/GetDocumentDownloadThumbnailRequestTest.php b/tests/Feature/Requests/Document/Thumbnail/GetDocumentDownloadThumbnailRequestTest.php index 8cb0d141..f267abd7 100644 --- a/tests/Feature/Requests/Document/Thumbnail/GetDocumentDownloadThumbnailRequestTest.php +++ b/tests/Feature/Requests/Document/Thumbnail/GetDocumentDownloadThumbnailRequestTest.php @@ -2,6 +2,7 @@ use CodebarAg\DocuWare\Connectors\DocuWareStaticConnector; use CodebarAg\DocuWare\DTO\Config; +use CodebarAg\DocuWare\DTO\DocumentThumbnail; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Requests\Document\DeleteDocumentRequest; use CodebarAg\DocuWare\Requests\Document\PostDocumentRequest; @@ -44,6 +45,9 @@ $this->assertSame('image/png', $contents->mime); $this->assertSame(282, strlen($contents->data)); + + $this->assertInstanceOf(DocumentThumbnail::class, $contents); + Event::assertDispatched(DocuWareResponseLog::class); $this->connector->send(new DeleteDocumentRequest( diff --git a/tests/Feature/Requests/Fields/GetFieldsRequestTest.php b/tests/Feature/Requests/Fields/GetFieldsRequestTest.php index 81dc4634..df327599 100644 --- a/tests/Feature/Requests/Fields/GetFieldsRequestTest.php +++ b/tests/Feature/Requests/Fields/GetFieldsRequestTest.php @@ -2,6 +2,7 @@ use CodebarAg\DocuWare\Connectors\DocuWareStaticConnector; use CodebarAg\DocuWare\DTO\Config; +use CodebarAg\DocuWare\DTO\Field; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Requests\Fields\GetFieldsRequest; use CodebarAg\DocuWare\Support\EnsureValidCookie; @@ -32,6 +33,12 @@ $fields = $this->connector->send(new GetFieldsRequest($fileCabinetId))->dto(); $this->assertInstanceOf(Collection::class, $fields); + + foreach ($fields as $field){ + $this->assertInstanceOf(Field::class, $field); + } + $this->assertNotCount(0, $fields); + Event::assertDispatched(DocuWareResponseLog::class); }); diff --git a/tests/Feature/Requests/FileCabinets/GetFileCabinetsRequestTest.php b/tests/Feature/Requests/FileCabinets/GetFileCabinetsRequestTest.php index 841d9f98..4bfeceb2 100644 --- a/tests/Feature/Requests/FileCabinets/GetFileCabinetsRequestTest.php +++ b/tests/Feature/Requests/FileCabinets/GetFileCabinetsRequestTest.php @@ -2,6 +2,7 @@ use CodebarAg\DocuWare\Connectors\DocuWareStaticConnector; use CodebarAg\DocuWare\DTO\Config; +use CodebarAg\DocuWare\DTO\FileCabinet; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Requests\FileCabinets\GetFileCabinetsRequest; use CodebarAg\DocuWare\Support\EnsureValidCookie; @@ -31,6 +32,11 @@ $fileCabinets = $this->connector->send(new GetFileCabinetsRequest())->dto(); $this->assertInstanceOf(Collection::class, $fileCabinets); + + foreach ($fileCabinets as $fileCabinet){ + $this->assertInstanceOf(FileCabinet::class, $fileCabinet); + } + $this->assertNotCount(0, $fileCabinets); Event::assertDispatched(DocuWareResponseLog::class); diff --git a/tests/Feature/Requests/Organization/GetOrganizationsRequestTest.php b/tests/Feature/Requests/Organization/GetOrganizationsRequestTest.php index 6c2534a0..77161157 100644 --- a/tests/Feature/Requests/Organization/GetOrganizationsRequestTest.php +++ b/tests/Feature/Requests/Organization/GetOrganizationsRequestTest.php @@ -2,6 +2,7 @@ use CodebarAg\DocuWare\Connectors\DocuWareStaticConnector; use CodebarAg\DocuWare\DTO\Config; +use CodebarAg\DocuWare\DTO\OrganizationIndex; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Requests\Organization\GetOrganizationsRequest; use CodebarAg\DocuWare\Support\EnsureValidCookie; @@ -30,6 +31,11 @@ $organizations = $this->connector->send(new GetOrganizationsRequest())->dto(); $this->assertInstanceOf(Collection::class, $organizations); + + foreach ($organizations as $organization){ + $this->assertInstanceOf(OrganizationIndex::class, $organization); + } + $this->assertNotCount(0, $organizations); Event::assertDispatched(DocuWareResponseLog::class); });