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

PurchaseClientTest::getPurchaseHistory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 0
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