-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDownPaymentInvoiceTest.php
More file actions
110 lines (84 loc) · 3.39 KB
/
DownPaymentInvoiceTest.php
File metadata and controls
110 lines (84 loc) · 3.39 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
<?php
declare(strict_types=1);
namespace Sysix\LexOffice\Tests\Clients;
use GuzzleHttp\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Sysix\LexOffice\Clients\DownPaymentInvoice;
use Sysix\LexOffice\Clients\VoucherList;
use Sysix\LexOffice\Tests\TestClient;
final class DownPaymentInvoiceTest extends TestClient
{
public function testGet(): void
{
[$api, $stub] = $this->createClientMockObject(DownPaymentInvoice::class);
$response = $stub->get('resource-id');
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals('GET', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/down-payment-invoices/resource-id',
$api->getRequest()->getUri()->__toString()
);
}
public function testGetAll(): void
{
$this->expectDeprecationV1Warning('getAll');
[$api, $stub] = $this->createClientMultiMockObject(
DownPaymentInvoice::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=downpaymentinvoice&voucherStatus=draft%2Copen%2Cpaid%2Cpaidoff%2Cvoided%2Caccepted%2Crejected&size=100&sort=voucherNumber%2CDESC',
$api->getRequest()->getUri()->__toString()
);
}
public function testGetVoucherListClient(): void
{
[, $stub] = $this->createClientMockObject(DownPaymentInvoice::class);
$client = $stub->getVoucherListClient();
$this->assertInstanceOf(VoucherList::class, $client);
}
public function testDocument(): void
{
[$api, $stub] = $this->createClientMockObject(DownPaymentInvoice::class);
$response = $stub->document('resource-id');
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals('GET', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/down-payment-invoices/resource-id/document',
$api->getRequest()->getUri()->__toString()
);
}
public function testDocumentContent(): void
{
[$api, $stub] = $this->createClientMultiMockObject(
DownPaymentInvoice::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(
DownPaymentInvoice::class,
[
new Response(500),
new Response()
]
);
$response = $stub->document('resource-id', true);
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals(500, $response->getStatusCode());
}
}