Passed
Push — master ( 70d4fa...5d64ac )
by Dominic
03:42
created

OrderTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 28
c 1
b 0
f 0
dl 0
loc 73
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A an_order_can_be_captured() 0 8 1
A an_order_can_be_retrieved() 0 8 1
A setUp() 0 4 1
A an_order_can_be_refunded() 0 10 1
A the_client_can_return_an_order_resource() 0 7 1
A orders_can_be_created() 0 8 1
A an_order_can_be_cancelled() 0 8 1
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);
0 ignored issues
show
Bug Best Practice introduced by
The property mockClient does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
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