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-2020, 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\event\InstallmentWasStarted; |
17
|
|
|
use hiqdev\php\billing\charge\modifiers\Leasing; |
|
|
|
|
18
|
|
|
use hiqdev\php\billing\price\SinglePrice; |
19
|
|
|
use hiqdev\php\billing\tests\unit\action\ActionTest; |
20
|
|
|
use hiqdev\php\billing\type\Type; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @author Andrii Vasyliev <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class InstallmentTest extends ActionTest |
26
|
|
|
{ |
27
|
|
|
protected $reason = 'test reason string'; |
28
|
|
|
|
29
|
|
|
protected function setUp(): void |
30
|
|
|
{ |
31
|
|
|
parent::setUp(); |
32
|
|
|
$this->type = new Type(Type::ANY, 'monthly,installment'); |
33
|
|
|
$this->price = new SinglePrice(5, $this->type, $this->target, null, $this->prepaid, $this->money); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
protected function buildInstallment($term) |
37
|
|
|
{ |
38
|
|
|
$month = (new DateTimeImmutable())->modify('first day of this month midnight'); |
39
|
|
|
|
40
|
|
|
return (new Installment())->since($month)->lasts($term); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testCreateMonth() |
44
|
|
|
{ |
45
|
|
|
$installment = $this->buildInstallment('12 months'); |
46
|
|
|
$period = $installment->getTerm(); |
47
|
|
|
$this->assertInstanceOf(MonthPeriod::class, $period); |
48
|
|
|
$this->assertSame(12, $period->getValue()); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function testTill() |
52
|
|
|
{ |
53
|
|
|
$this->expectException(\Exception::class); |
54
|
|
|
$this->buildInstallment('month')->till('08.2024'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testReason() |
58
|
|
|
{ |
59
|
|
|
$installment = $this->buildInstallment('12 months'); |
60
|
|
|
$installment = $installment->reason($this->reason); |
61
|
|
|
$this->assertSame($this->reason, $installment->getReason()->getValue()); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testCreateYear() |
65
|
|
|
{ |
66
|
|
|
$installment = $this->buildInstallment('1 year'); |
67
|
|
|
$period = $installment->getTerm(); |
68
|
|
|
$this->assertInstanceOf(YearPeriod::class, $period); |
69
|
|
|
$this->assertSame(1, $period->getValue()); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function testModifyCharge() |
73
|
|
|
{ |
74
|
|
|
$installment = $this->buildInstallment('6 months'); |
75
|
|
|
$action = $this->createAction($this->prepaid->multiply(2)); |
76
|
|
|
$charge = $this->calculator->calculateCharge($this->price, $action); |
77
|
|
|
$charges = $installment->modifyCharge($charge, $action); |
78
|
|
|
$event = $charges[0]->releaseEvents()[0]; |
79
|
|
|
$this->assertInstanceOf(InstallmentWasStarted::class, $event); |
80
|
|
|
$this->assertIsArray($charges); |
81
|
|
|
$this->assertSame(1, count($charges)); |
82
|
|
|
$this->assertEquals($charge, $charges[0]); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths