Skip to content

Commit

Permalink
Dto checks
Browse files Browse the repository at this point in the history
  • Loading branch information
RhysLees committed Oct 13, 2023
1 parent fed06d9 commit f388f1a
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/Feature/Requests/Dialogs/GetDialogsRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
$dialogId
))->dto();


$this->assertIsInt($count);

$this->assertSame(1, $count);

Event::assertDispatched(DocuWareResponseLog::class);

$this->connector->send(new DeleteDocumentRequest(
Expand Down
1 change: 1 addition & 0 deletions tests/Feature/Requests/Document/GetDocumentRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions tests/Feature/Requests/Fields/GetFieldsRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});

0 comments on commit f388f1a

Please sign in to comment.