| 1 | <?php |
||
| 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 |