1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace tbclla\RevolutMerchant\Tests; |
4
|
|
|
|
5
|
|
|
use Orchestra\Testbench\TestCase; |
6
|
|
|
use tbclla\RevolutMerchant\Client; |
7
|
|
|
use tbclla\RevolutMerchant\Resources\Order; |
8
|
|
|
use tbclla\RevolutMerchant\Resources\Resource; |
9
|
|
|
|
10
|
|
|
class OrderTest extends TestCase |
11
|
|
|
{ |
12
|
|
|
protected function setUp() : void |
13
|
|
|
{ |
14
|
|
|
parent::setUp(); |
15
|
|
|
$this->mockClient = $this->mock(Client::class); |
|
|
|
|
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
/** @test */ |
19
|
|
|
public function the_client_can_return_an_order_resource() |
20
|
|
|
{ |
21
|
|
|
$client = new Client('example_key'); |
22
|
|
|
$order = $client->order(); |
23
|
|
|
|
24
|
|
|
$this->assertInstanceOf(Order::class, $order); |
25
|
|
|
$this->assertInstanceOf(Resource::class, $order); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** @test */ |
29
|
|
|
public function orders_can_be_created() |
30
|
|
|
{ |
31
|
|
|
$this->mockClient->shouldReceive()->post(Order::ENDPOINT, [ |
32
|
|
|
'json' => [] |
33
|
|
|
]); |
34
|
|
|
|
35
|
|
|
$order = new Order($this->mockClient); |
36
|
|
|
$order->create([]); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** @test */ |
40
|
|
|
public function an_order_can_be_retrieved() |
41
|
|
|
{ |
42
|
|
|
$id = 'abc123'; |
43
|
|
|
|
44
|
|
|
$this->mockClient->shouldReceive()->get(Order::ENDPOINT . '/' . $id); |
45
|
|
|
|
46
|
|
|
$order = new Order($this->mockClient); |
47
|
|
|
$order->get($id); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** @test */ |
51
|
|
|
public function an_order_can_be_captured() |
52
|
|
|
{ |
53
|
|
|
$id = 'abc123'; |
54
|
|
|
|
55
|
|
|
$this->mockClient->shouldReceive()->post(Order::ENDPOINT . '/' . $id . '/capture'); |
56
|
|
|
|
57
|
|
|
$order = new Order($this->mockClient); |
58
|
|
|
$order->capture($id); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** @test */ |
62
|
|
|
public function an_order_can_be_cancelled() |
63
|
|
|
{ |
64
|
|
|
$id = 'abc123'; |
65
|
|
|
|
66
|
|
|
$this->mockClient->shouldReceive()->post(Order::ENDPOINT . '/' . $id . '/cancel'); |
67
|
|
|
|
68
|
|
|
$order = new Order($this->mockClient); |
69
|
|
|
$order->cancel($id); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** @test */ |
73
|
|
|
public function an_order_can_be_refunded() |
74
|
|
|
{ |
75
|
|
|
$id = 'abc123'; |
76
|
|
|
|
77
|
|
|
$this->mockClient->shouldReceive()->post(Order::ENDPOINT . '/' . $id . '/refund', [ |
78
|
|
|
'json' => [] |
79
|
|
|
]); |
80
|
|
|
|
81
|
|
|
$order = new Order($this->mockClient); |
82
|
|
|
$order->refund($id, []); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|