Skip to content

Commit

Permalink
Implement test for get all refunds
Browse files Browse the repository at this point in the history
  • Loading branch information
jswift committed Sep 28, 2020
1 parent 6074d84 commit d245d0b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/BigCommerce/ResponseModels/Order/RefundsResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

namespace BigCommerce\ApiV3\ResponseModels\Order;

use BigCommerce\ApiV3\ResourceModels\Order\RefundQuote;
use BigCommerce\ApiV3\ResourceModels\Order\Refund;
use BigCommerce\ApiV3\ResponseModels\PaginatedResponse;

class RefundsResponse extends PaginatedResponse
{
/**
* @return RefundQuote[]
* @return Refund[]
*/
public function refunds(): array
{
return $this->getData();
}
protected function resourceClass(): string
{
return RefundQuote::class;
return Refund::class;
}
}
8 changes: 7 additions & 1 deletion tests/BigCommerce/Orders/RefundsApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ public function testCanCreateQuoteRefund()

public function testCanGetAll()
{
$this->markTestIncomplete();
$this->setReturnData('orders__order_refunds__get_all.json', 201);
$orderId = 1;

$response = $this->getApi()->order($orderId)->refunds()->getAll();
$this->assertCount(1, $response->refunds());
$this->assertCount(1, $response->refunds()[0]->items);
$this->assertInstanceOf(OrderRefundItem::class, $response->refunds()[0]->items[0]);
}

public function testCanCreateRefund()
Expand Down
42 changes: 42 additions & 0 deletions tests/BigCommerce/responses/orders__order_refunds__get_all.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"data": [{
"id": 1,
"order_id": 1,
"user_id": 1,
"created": "",
"reason": "test reason",
"total_amount": 1.99,
"total_tax": 1,
"items": [
{
"item_type": "HANDLING",
"item_id": 1,
"reason": "",
"quantity": 1,
"requested_amount": 0.05
}
],
"payments": [
{
"id": 1,
"provider_id": "checkout_paypalexpress",
"amount": 1.99,
"offline": true,
"is_declined": true,
"declined_message": ""
}
]
}],
"meta": {
"pagination": {
"total": 1,
"count": 1,
"per_page": 50,
"current_page": 1,
"total_pages": 1,
"links": {
"current": "?page=1&limit=50"
}
}
}
}

0 comments on commit d245d0b

Please sign in to comment.