Total Complexity | 2 |
Total Lines | 21 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
21 | class GrowingDiscountTest extends FixedDiscountTest |
||
22 | { |
||
23 | protected function buildDiscount($value) |
||
24 | { |
||
25 | $month = (new DateTimeImmutable())->modify('first day of this month midnight'); |
||
26 | |||
27 | return (new GrowingDiscount($value))->since($month)->every('month')->till('3000-01'); |
||
28 | } |
||
29 | |||
30 | public function assertCharges($fd, $sum) |
||
31 | { |
||
32 | $action = $this->createAction($this->prepaid->multiply(2)); |
||
33 | $charge = $this->calculator->calculateCharge($this->price, $action); |
||
34 | $charges = $fd->modifyCharge($charge, $action); |
||
35 | $this->assertIsArray($charges); |
||
36 | $this->assertSame(2, count($charges)); |
||
37 | $this->assertSame($charge, $charges[0]); |
||
38 | $discount = $charges[1]; |
||
39 | $this->assertInstanceOf(Charge::class, $discount); |
||
40 | $this->assertEquals(Quantity::items(0), $discount->getUsage()); |
||
41 | $this->assertEquals($sum->multiply(-1), $discount->getSum()); |
||
42 | } |
||
44 |