Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Новый Content-Type "application/atom+xml" для ответа
Browse files Browse the repository at this point in the history
Fixes #103
  • Loading branch information
sanmai committed Feb 19, 2021
1 parent 0924f83 commit cb6ed54
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/CdekClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 10 additions & 1 deletion tests/CdekClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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')));
Expand Down

0 comments on commit cb6ed54

Please sign in to comment.