Completed
Push — master ( b736eb...f06be5 )
by Laurens
03:50 queued 01:55
created

PurchaseClientTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 47
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPurchaseHistory() 0 20 1
A getPurchase() 0 17 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi\Tests\Unit;
6
7
use LauLamanApps\IzettleApi\API\Purchase\Purchase;
8
use LauLamanApps\IzettleApi\API\Purchase\PurchaseHistory;
9
use LauLamanApps\IzettleApi\PurchaseClient;
10
use LauLamanApps\IzettleApi\Tests\Unit\Client\Purchase\PurchaseParserTest;
11
use Ramsey\Uuid\Uuid;
12
13
/**
14
 * @small
15
 */
16
final class PurchaseClientTest extends AbstractClientTest
17
{
18
    /**
19
     * @test
20
     */
21
    public function getPurchaseHistory()
22
    {
23
        $method = 'get';
24
        $options = [
25
            'headers' => [
26
                'Authorization' => sprintf('Bearer %s', self::ACCESS_TOKEN)
27
            ],
28
            'query' => null,
29
        ];
30
31
        $return = [
32
            'firstPurchaseHash' => Uuid::uuid1(),
33
            'lastPurchaseHash' => Uuid::uuid1(),
34
            'purchases' => [],
35
        ];
36
37
        $purchaseClient = new PurchaseClient($this->getGuzzleClient($method, PurchaseClient::GET_PURCHASES, $options, $return), $this->getAccessToken());
38
        $purchaseHistory = $purchaseClient->getPurchaseHistory();
39
        self::assertInstanceOf(PurchaseHistory::class, $purchaseHistory);
40
    }
41
42
    /**
43
     * @test
44
     */
45
    public function getPurchase()
46
    {
47
        $purchaseUuid = Uuid::uuid1();
48
        $method = 'get';
49
        $url = sprintf(PurchaseClient::GET_PURCHASE, (string) $purchaseUuid);
50
        $options = [
51
            'headers' => [
52
                'Authorization' => sprintf('Bearer %s', self::ACCESS_TOKEN)
53
            ],
54
            'query' => null,
55
        ];
56
        $return = (new PurchaseParserTest())->getData();
57
58
        $purchaseClient = new PurchaseClient($this->getGuzzleClient($method, $url, $options, $return), $this->getAccessToken());
59
        $purchase = $purchaseClient->getPurchase($purchaseUuid);
60
        self::assertInstanceOf(Purchase::class, $purchase);
61
    }
62
}
63