From 95d9fb14d86e6a120f05cc1527bd775e3c0dbb85 Mon Sep 17 00:00:00 2001 From: "zoltan.horvath" Date: Mon, 29 Jul 2024 16:16:27 +0200 Subject: [PATCH 1/2] add-check-if-attributes-exist --- src/Resources/Efactura.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Resources/Efactura.php b/src/Resources/Efactura.php index 588db81..e2aeed3 100644 --- a/src/Resources/Efactura.php +++ b/src/Resources/Efactura.php @@ -41,6 +41,10 @@ public function upload(string $xml_path, string $tax_identification_number, Uplo /** @var array $response */ $response = $this->transporter->requestObject($payload); + if (! array_key_exists('@attributes', $response)) { + throw new RuntimeException($response['message']); + } + return CreateUploadResponse::from($response['@attributes']); } From 21050f1ec25dbb84480a03e8142b602007836987 Mon Sep 17 00:00:00 2001 From: "zoltan.horvath" Date: Mon, 29 Jul 2024 16:17:58 +0200 Subject: [PATCH 2/2] remove-unnecessary-testcase --- tests/Transporters/HttpTransporterObject.php | 24 -------------------- 1 file changed, 24 deletions(-) diff --git a/tests/Transporters/HttpTransporterObject.php b/tests/Transporters/HttpTransporterObject.php index 7fb2e2d..c7634b5 100644 --- a/tests/Transporters/HttpTransporterObject.php +++ b/tests/Transporters/HttpTransporterObject.php @@ -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', []);