1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Moip\Tests; |
4
|
|
|
|
5
|
|
|
use Mockery as m; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* class MoipTest. |
9
|
|
|
*/ |
10
|
|
|
class MoipTest extends MoipTestCase |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Test if endpoint production is valid. |
14
|
|
|
*/ |
15
|
|
|
public function testShouldReceiveEndpointProductionIsValid() |
16
|
|
|
{ |
17
|
|
|
$expected = 'api.moip.com.br'; |
18
|
|
|
$actual = constant('\Moip\Moip::ENDPOINT_PRODUCTION'); |
19
|
|
|
|
20
|
|
|
$this->assertEquals($expected, $actual); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Test if endpoint sandbox is valid. |
25
|
|
|
*/ |
26
|
|
|
public function testShouldReceiveSandboxProductionIsValid() |
27
|
|
|
{ |
28
|
|
|
$expected = 'sandbox.moip.com.br'; |
29
|
|
|
$actual = constant('\Moip\Moip::ENDPOINT_SANDBOX'); |
30
|
|
|
|
31
|
|
|
$this->assertEquals($expected, $actual); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Test if const CLIENT is valid. |
36
|
|
|
*/ |
37
|
|
|
public function testShouldReceiveClientIsValid() |
38
|
|
|
{ |
39
|
|
|
$client = 'Moip SDK'; |
40
|
|
|
$const_client = constant('\Moip\Moip::CLIENT'); |
41
|
|
|
|
42
|
|
|
$this->assertEquals($client, $const_client); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* test create connection. |
47
|
|
|
*/ |
48
|
|
|
public function testCreateConnection() |
49
|
|
|
{ |
50
|
|
|
$http_connection = m::mock('\Moip\Http\HTTPConnection'); |
51
|
|
|
$http_header_name = 'Accept'; |
52
|
|
|
$http_header_value = 'application/json'; |
53
|
|
|
|
54
|
|
|
$http_connection->shouldReceive('initialize') |
55
|
|
|
->withArgs([$this->moip->getEndpoint(), true]) |
56
|
|
|
->once() |
57
|
|
|
->andReturnNull(); |
58
|
|
|
|
59
|
|
|
$http_connection->shouldReceive('addHeader') |
60
|
|
|
->withArgs([$http_header_name, $http_header_value]) |
61
|
|
|
->once() |
62
|
|
|
->andReturn(true); |
63
|
|
|
|
64
|
|
|
$http_connection->shouldReceive('setAuthenticator') |
65
|
|
|
->once() |
66
|
|
|
->andReturnNull(); |
67
|
|
|
|
68
|
|
|
$this->assertEquals($http_connection, $this->moip->createConnection($http_connection)); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Test should return instance of \Moip\Resource\Customer. |
73
|
|
|
*/ |
74
|
|
|
public function testShouldReceiveInstanceOfCustomer() |
75
|
|
|
{ |
76
|
|
|
$customer = new \Moip\Resource\Customer($this->moip); |
77
|
|
|
|
78
|
|
|
$this->assertEquals($customer, $this->moip->customers()); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Test should return instance of \Moip\Resource\Entry. |
83
|
|
|
*/ |
84
|
|
|
public function testShouldReceiveInstanceOfEntry() |
85
|
|
|
{ |
86
|
|
|
$entry = new \Moip\Resource\Entry($this->moip); |
87
|
|
|
|
88
|
|
|
$this->assertEquals($entry, $this->moip->entries()); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Test should return instance of \Moip\Resource\Orders. |
93
|
|
|
*/ |
94
|
|
|
public function testShouldReceiveInstanceOfOrders() |
95
|
|
|
{ |
96
|
|
|
$orders = new \Moip\Resource\Orders($this->moip); |
97
|
|
|
|
98
|
|
|
$this->assertEquals($orders, $this->moip->orders()); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Test should return instance of \Moip\Resource\Payment. |
103
|
|
|
*/ |
104
|
|
|
public function testShouldReceiveInstanceOfPayment() |
105
|
|
|
{ |
106
|
|
|
$payment = new \Moip\Resource\Payment($this->moip); |
107
|
|
|
|
108
|
|
|
$this->assertEquals($payment, $this->moip->payments()); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Test should return instance of \Moip\Resource\Multiorders. |
113
|
|
|
*/ |
114
|
|
|
public function testShouldReceiveInstanceOfMultiorders() |
115
|
|
|
{ |
116
|
|
|
$multiorders = new \Moip\Resource\Multiorders($this->moip); |
117
|
|
|
|
118
|
|
|
$this->assertEquals($multiorders, $this->moip->multiorders()); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function testShouldGetEndpoint() |
122
|
|
|
{ |
123
|
|
|
$expected = constant('\Moip\Moip::ENDPOINT_SANDBOX'); |
124
|
|
|
|
125
|
|
|
$this->assertEquals($expected, $this->moip->getEndpoint()); |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|