-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathQuotationTest.php
More file actions
144 lines (110 loc) · 4.26 KB
/
QuotationTest.php
File metadata and controls
144 lines (110 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
declare(strict_types=1);
namespace Sysix\LexOffice\Tests\Clients;
use GuzzleHttp\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Sysix\LexOffice\Clients\Quotation;
use Sysix\LexOffice\Clients\VoucherList;
use Sysix\LexOffice\Tests\TestClient;
final class QuotationTest extends TestClient
{
public function testCreate(): void
{
[$api, $stub] = $this->createClientMockObject(Quotation::class);
$response = $stub->create([
'version' => 0
]);
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals('POST', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/quotations',
$api->getRequest()->getUri()->__toString()
);
}
public function testCreateFinalized(): void
{
[$api, $stub] = $this->createClientMockObject(Quotation::class);
$response = $stub->create([
'version' => 0
], true);
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals('POST', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/quotations?finalize=true',
$api->getRequest()->getUri()->__toString()
);
}
public function testGet(): void
{
[$api, $stub] = $this->createClientMockObject(Quotation::class);
$response = $stub->get('resource-id');
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals('GET', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/quotations/resource-id',
$api->getRequest()->getUri()->__toString()
);
}
public function testGetAll(): void
{
$this->expectDeprecationV1Warning('getAll');
[$api, $stub] = $this->createClientMultiMockObject(
Quotation::class,
[new Response(200, [], '{"content": [], "totalPages": 1}')]
);
$response = $stub->getAll();
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals('GET', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/voucherlist?page=0&voucherType=quotation&voucherStatus=draft%2Copen%2Cpaid%2Cpaidoff%2Cvoided%2Caccepted%2Crejected&size=100&sort=voucherNumber%2CDESC',
$api->getRequest()->getUri()->__toString()
);
}
public function testGetVoucherListClient(): void
{
[, $stub] = $this->createClientMockObject(Quotation::class);
$client = $stub->getVoucherListClient();
$this->assertInstanceOf(VoucherList::class, $client);
}
public function testDocument(): void
{
[$api, $stub] = $this->createClientMockObject(Quotation::class);
$response = $stub->document('resource-id');
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals('GET', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/quotations/resource-id/document',
$api->getRequest()->getUri()->__toString()
);
}
public function testDocumentContent(): void
{
[$api, $stub] = $this->createClientMultiMockObject(
Quotation::class,
[
new Response(200, ['Content-Type' => 'application/json'], '{"documentFileId": "fake-id"}'),
new Response()
]
);
$response = $stub->document('resource-id', true);
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals('GET', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/files/fake-id',
$api->getRequest()->getUri()->__toString()
);
}
public function testFailedDocumentContent(): void
{
[, $stub] = $this->createClientMultiMockObject(
Quotation::class,
[
new Response(500),
new Response()
]
);
$response = $stub->document('resource-id', true);
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals(500, $response->getStatusCode());
}
}