Completed
Push — master ( eac57c...9ff768 )
by Laurens
02:04
created

PurchaseHistoryTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 49
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A purchaseHistory() 0 20 1
A getGeneratedPurchase() 0 22 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\iZettleApi\Tests\Unit\Api\Purchase;
6
7
use DateTime;
8
use LauLamanApps\iZettleApi\API\Purchase\Purchase;
9
use LauLamanApps\iZettleApi\API\Purchase\PurchaseHistory;
10
use LauLamanApps\iZettleApi\API\Purchase\User;
11
use Mockery;
12
use Money\Money;
13
use PHPUnit\Framework\TestCase;
14
use Ramsey\Uuid\Uuid;
15
use stdClass;
16
17
/**
18
 * @small
19
 */
20
final class PurchaseHistoryTest extends TestCase
21
{
22
    /**
23
     * @test
24
     */
25
    public function purchaseHistory()
26
    {
27
        $initialPurchases = 2;
28
        $purchaseHistory =  new PurchaseHistory(
29
            '',
30
            '',
31
            [$this->getGeneratedPurchase(), $this->getGeneratedPurchase(), new stdClass()]
32
        );
33
34
        self::assertEquals($initialPurchases, count($purchaseHistory->getPurchases()));
35
36
        $purchase = $this->getGeneratedPurchase();
37
        $purchaseHistory ->addPurchase($purchase);
38
39
        self::assertEquals(($initialPurchases +1), count($purchaseHistory->getPurchases()));
40
41
        $purchaseHistory ->removePurchase($purchase);
42
43
        self::assertEquals($initialPurchases, count($purchaseHistory->getPurchases()));
44
    }
45
46
    private function getGeneratedPurchase(): Purchase
47
    {
48
        return new Purchase(
49
            (string) Uuid::uuid1(),
50
        Uuid::uuid1(),
51
        new DateTime(),
52
        null,
53
        '',
54
        new User(0, ''),
55
        0,
56
        0,
57
        Money::EUR(0),
58
        Money::EUR(0),
59
        [],
60
        [],
61
        [],
62
        false,
63
        null,
64
        false,
65
        false
66
        );
67
    }
68
}
69