mirror of
https://github.com/opdavies/glassboxx-sdk-php.git
synced 2025-02-17 22:50:48 +00:00
Allow for easily sending multiple order items
This allows for the sending of multiple items in a single order, by adding a new `OrderItem` class and moving all of the order item specific fields from the `Order` to an individual item. These can then be assigned to an order using the `withOrderItems()` method as an array of order items. Fixes #19
This commit is contained in:
parent
0ed99797f5
commit
ae766763b2
9 changed files with 86 additions and 53 deletions
|
@ -7,6 +7,7 @@ namespace Opdavies\Glassboxx\Tests\Glassboxx\Request;
|
|||
use DateTime;
|
||||
use Opdavies\Glassboxx\Request\OrderRequest;
|
||||
use Opdavies\Glassboxx\Tests\Glassboxx\TestCase;
|
||||
use Opdavies\Glassboxx\ValueObject\OrderItemInterface;
|
||||
use Symfony\Component\HttpClient\MockHttpClient;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
|
@ -56,6 +57,7 @@ final class OrderRequestTest extends TestCase
|
|||
|
||||
$request = (new OrderRequest($client))
|
||||
->forOrder($this->getMockOrder())
|
||||
->withOrderItems([$this->getMockOrderItem()])
|
||||
->withAuthToken($authTokenRequest->getToken())
|
||||
->withConfig($this->config)
|
||||
->setCreatedDate('2020-06-04 12:00:00');
|
||||
|
@ -63,4 +65,14 @@ final class OrderRequestTest extends TestCase
|
|||
// A successful response returns the original body.
|
||||
$this->assertSame(json_encode($body), $request->execute());
|
||||
}
|
||||
|
||||
private function getMockOrderItem(): OrderItemInterface
|
||||
{
|
||||
$orderItem = $this->getMockBuilder(OrderItemInterface::class)
|
||||
->getMock();
|
||||
$orderItem->method('getPrice')->willReturn(7.99);
|
||||
$orderItem->method('getSku')->willReturn('this-is-the-first-sku');
|
||||
|
||||
return $orderItem;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue