Passed
Branch master (9ff768)
by Laurens
02:02
created

PurchaseHistoryTest::getGeneratedPurchase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 22
rs 9.2
c 1
b 0
f 0
cc 1
eloc 16
nc 1
nop 0
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