1 | <?php |
||
2 | /** |
||
3 | * PHP Billing Library |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/php-billing |
||
6 | * @package php-billing |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hiqdev\php\billing\tests\unit\charge\modifiers; |
||
12 | |||
13 | use DateTimeImmutable; |
||
14 | use hiqdev\php\billing\charge\modifiers\addons\MonthPeriod; |
||
15 | use hiqdev\php\billing\charge\modifiers\addons\YearPeriod; |
||
16 | use hiqdev\php\billing\charge\modifiers\Leasing; |
||
17 | use hiqdev\php\billing\tests\unit\action\ActionTest; |
||
18 | |||
19 | /** |
||
20 | * @author Andrii Vasyliev <[email protected]> |
||
21 | */ |
||
22 | class LeasingTest extends ActionTest |
||
23 | { |
||
24 | protected $reason = 'test reason string'; |
||
25 | |||
26 | protected function buildLeasing($term) |
||
27 | { |
||
28 | $month = (new DateTimeImmutable())->modify('first day of this month midnight'); |
||
29 | |||
30 | return (new Leasing())->since($month)->lasts($term); |
||
31 | } |
||
32 | |||
33 | public function testCreateMonth() |
||
34 | { |
||
35 | $leasing = $this->buildLeasing('12 months'); |
||
36 | $period = $leasing->getTerm(); |
||
37 | $this->assertInstanceOf(MonthPeriod::class, $period); |
||
38 | $this->assertSame(12, $period->getValue()); |
||
39 | } |
||
40 | |||
41 | public function testTill() |
||
42 | { |
||
43 | $this->expectException(\Exception::class); |
||
44 | $this->buildLeasing('month')->till('08.2018'); |
||
45 | } |
||
46 | |||
47 | public function testReason() |
||
48 | { |
||
49 | $leasing = $this->buildLeasing('12 months'); |
||
50 | $leasing = $leasing->reason($this->reason); |
||
51 | $this->assertSame($this->reason, $leasing->getReason()->getValue()); |
||
52 | } |
||
53 | |||
54 | public function testCreateYear() |
||
55 | { |
||
56 | $leasing = $this->buildLeasing('1 year'); |
||
57 | $period = $leasing->getTerm(); |
||
58 | $this->assertInstanceOf(YearPeriod::class, $period); |
||
59 | $this->assertSame(1, $period->getValue()); |
||
60 | } |
||
61 | |||
62 | public function testModifyCharge() |
||
63 | { |
||
64 | $leasing = $this->buildLeasing('6 months'); |
||
65 | $action = $this->createAction($this->prepaid->multiply(2)); |
||
66 | $charge = $this->calculator->calculateCharge($this->price, $action); |
||
67 | $charges = $leasing->modifyCharge($charge, $action); |
||
68 | $this->assertInternalType('array', $charges); |
||
0 ignored issues
–
show
|
|||
69 | $this->assertSame(1, count($charges)); |
||
70 | $this->assertEquals($charge, $charges[0]); |
||
71 | } |
||
72 | } |
||
73 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.