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

Commit

Permalink
Merge 8cfd36e into eb09d8f
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmai committed Dec 20, 2018
2 parents eb09d8f + 8cfd36e commit 1bd3706
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Responses/DeliveryResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ public function getRequests()
return $this->requests;
}

/**
* @return \Pipeline\Standard|CallCourier[]
*/
public function getCalls()
{
return fromArray($this->calls)->filter(function (CallCourier $call) {
return $call->getNumber() !== '';
});
}

/**
* @JMS\PostDeserialize
*
Expand Down
22 changes: 22 additions & 0 deletions tests/Deserialization/DeliveryResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,28 @@ public function test_missing_courier_call()
}
}

public function test_successful_request_with_call()
{
$response = $this->getSerializer()->deserialize(FixtureLoader::load('DeliveryRequestWithCallSuccess.xml'), DeliveryResponse::class, 'xml');

/** @var $response DeliveryResponse */
$this->assertInstanceOf(DeliveryResponse::class, $response);

$this->assertCount(1, $response->getOrders());

foreach ($response->getOrders() as $order) {
$this->assertSame('TESTING-123', $order->getNumber());
$this->assertSame('110000123', $order->getDispatchNumber());
}

$this->assertCount(1, $response->getMessages());
$this->assertCount(1, $response->getCalls());

foreach ($response->getCalls() as $call) {
$this->assertSame('22022033', $call->getNumber());
}
}

public function test_it_serializes_to_empty_json()
{
$response = new DeliveryResponse();
Expand Down
1 change: 1 addition & 0 deletions tests/Fixtures/data/DeliveryRequestWithCallSuccess.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><response><Call Number="22022033"/><Call Msg="Добавлено заявок 1"/><Order DispatchNumber="110000123" Number="TESTING-123"/><TraceId>e5341942156970a92</TraceId></response>

0 comments on commit 1bd3706

Please sign in to comment.