Skip to content

Commit

Permalink
Merge pull request #36 from zoltanhorvath2/fix-fatal-error-on-missing…
Browse files Browse the repository at this point in the history
…-attributes-on-upload
  • Loading branch information
ciungulete authored Jul 29, 2024
2 parents 73fe1cd + 21050f1 commit 4a76777
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
4 changes: 4 additions & 0 deletions src/Resources/Efactura.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public function upload(string $xml_path, string $tax_identification_number, Uplo
/** @var array<array-key, array{dateResponse: string, ExecutionStatus: string, index_incarcare: string}> $response */
$response = $this->transporter->requestObject($payload);

if (! array_key_exists('@attributes', $response)) {
throw new RuntimeException($response['message']);
}

return CreateUploadResponse::from($response['@attributes']);
}

Expand Down
24 changes: 0 additions & 24 deletions tests/Transporters/HttpTransporterObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,6 @@
);
});

test('request object tax identification number not found', function () {
$payload = Payload::create('PlatitorTvaRest/api/v8/ws/tva', []);

$response = new Response(200, [], json_encode(
[
'cod' => 200,
'message' => 'SUCCESS',
'found' => [],
'notFound' => [
0 => 387445633,
],
],
));

$this->client
->shouldReceive('sendRequest')
->once()
->andReturn($response);

expect(fn () => $this->http->requestObject($payload))
->toThrow(function (TaxIdentificationNumberNotFoundException $e) {
expect($e->getMessage())->toBe('Tax identification number not found');
});
});

test('request object client errors', function () {
$payload = Payload::create('PlatitorTvaRest/api/v8/ws/tva', []);
Expand Down

0 comments on commit 4a76777

Please sign in to comment.