Passed
Push — master ( 9ff768...b736eb )
by Laurens
02:33
created

PurchaseHistoryParserTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromResponse() 0 20 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi\Tests\Unit\Client\Purchase;
6
7
use LauLamanApps\IzettleApi\API\Purchase\PurchaseHistory;
8
use LauLamanApps\IzettleApi\Client\Purchase\PurchaseHistoryParser;
9
use Mockery;
10
use PHPUnit\Framework\TestCase;
11
use Psr\Http\Message\ResponseInterface;
12
13
/**
14
 * @small
15
 */
16
final class PurchaseHistoryParserTest extends TestCase
17
{
18
    /**
19
     * @test
20
     */
21
    public function createFromResponse(): void
22
    {
23
        $data = [
24
            'firstPurchaseHash' => $firstPurchaseHash = 'hash1',
25
            'lastPurchaseHash' => $lastPurchaseHash = 'hash2',
26
            'purchases' => [],
27
        ];
28
29
        $responseMock = Mockery::mock(ResponseInterface::class);
30
        $responseMock->shouldReceive('getBody')->andReturnSelf();
31
        $responseMock->shouldReceive('getContents')->andReturn(json_encode(
32
            $data
33
        ));
34
35
        $purchaseHistory = PurchaseHistoryParser::createFromResponse($responseMock);
36
37
        self::assertInstanceOf(PurchaseHistory::class, $purchaseHistory);
38
        self::assertSame($firstPurchaseHash, $purchaseHistory->getFirstPurchaseHash());
39
        self::assertSame($lastPurchaseHash, $purchaseHistory->getLastPurchaseHash());
40
    }
41
}
42