diff --git a/src/CdekClient.php b/src/CdekClient.php index aa6d0fb..fccbe12 100644 --- a/src/CdekClient.php +++ b/src/CdekClient.php @@ -328,6 +328,10 @@ private function isTextResponse(string $header): bool return true; } + if (0 === \strpos($header, 'application/atom+xml')) { + return true; + } + if (0 === \strpos($header, 'application/json')) { return true; } diff --git a/tests/CdekClientTest.php b/tests/CdekClientTest.php index bcad201..0ab86b9 100644 --- a/tests/CdekClientTest.php +++ b/tests/CdekClientTest.php @@ -117,7 +117,7 @@ public function test_client_can_read_xml_response() $this->assertArrayHasKey('xml_request', $this->lastRequestOptions['form_params']); } - public function test_client_can_read_xml_response_with_alternative_content_type() + public function test_client_can_read_xml_response_with_yet_alternative_content_type() { $client = new CdekClient('foo', 'bar', $this->getHttpClient('application/xml', FixtureLoader::load('StatusReportResponse.xml'))); $response = $client->sendStatusReportRequest(new StatusReportRequest()); @@ -126,6 +126,15 @@ public function test_client_can_read_xml_response_with_alternative_content_type( $this->assertInstanceOf(StatusReportResponse::class, $response); } + public function test_client_can_read_xml_response_with_alternative_content_type() + { + $client = new CdekClient('foo', 'bar', $this->getHttpClient('application/atom+xml', FixtureLoader::load('StatusReportResponse.xml'))); + $response = $client->sendStatusReportRequest(new StatusReportRequest()); + + /** @var $response StatusReportResponse */ + $this->assertInstanceOf(StatusReportResponse::class, $response); + } + public function test_client_can_read_json_response() { $client = new CdekClient('foo', 'bar', $this->getHttpClient('application/json', FixtureLoader::load('CalculationResponseError.json')));