-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathContactTest.php
More file actions
92 lines (69 loc) · 2.64 KB
/
ContactTest.php
File metadata and controls
92 lines (69 loc) · 2.64 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
<?php
declare(strict_types=1);
namespace Sysix\LexOffice\Tests\Clients;
use Psr\Http\Message\ResponseInterface;
use Sysix\LexOffice\Clients\Contact;
use Sysix\LexOffice\Tests\TestClient;
final class ContactTest extends TestClient
{
public function testGetPage(): void
{
[$api, $client] = $this->createClientMockObject(Contact::class);
$response = $client->getPage(0);
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals('GET', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/contacts?page=0&size=100',
$api->getRequest()->getUri()->__toString()
);
}
public function testGetPageWithFilters(): void
{
[$api, $client] = $this->createClientMockObject(Contact::class);
$client->email = 'john.doe@example.com';
$client->name = 'John Doe';
$client->number = 12345;
$client->customer = true;
$client->vendor = false;
$client->getPage(0);
$this->assertEquals(
$api->apiUrl . '/v1/contacts?page=0&email=john.doe%40example.com&name=John+Doe&number=12345&customer=1&vendor=0&size=100',
$api->getRequest()->getUri()->__toString()
);
}
public function testCreate(): void
{
[$api, $client] = $this->createClientMockObject(Contact::class);
$response = $client->create([
'version' => 0
]);
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals('POST', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/contacts',
$api->getRequest()->getUri()->__toString()
);
}
public function testGet(): void
{
[$api, $client] = $this->createClientMockObject(Contact::class);
$response = $client->get('resource-id');
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals('GET', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/contacts/resource-id',
$api->getRequest()->getUri()->__toString()
);
}
public function testUpdate(): void
{
[$api, $client] = $this->createClientMockObject(Contact::class);
$response = $client->update('resource-id', []);
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals('PUT', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/contacts/resource-id',
$api->getRequest()->getUri()->__toString()
);
}
}