1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace hiqdev\php\billing\tests\unit\price; |
6
|
|
|
|
7
|
|
|
use hiqdev\php\billing\price\ProgressivePrice; |
8
|
|
|
use hiqdev\php\billing\price\ProgressivePriceThresholdsDto; |
|
|
|
|
9
|
|
|
use hiqdev\php\billing\target\Target; |
10
|
|
|
use hiqdev\php\billing\type\Type; |
11
|
|
|
use hiqdev\php\units\Quantity; |
12
|
|
|
use Money\Money; |
13
|
|
|
use Money\Currency; |
14
|
|
|
|
15
|
|
|
class ProgressivePriceTest extends \PHPUnit\Framework\TestCase |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
protected ProgressivePrice $price; |
19
|
|
|
|
20
|
|
|
protected Target $target; |
21
|
|
|
|
22
|
|
|
protected Type $type; |
23
|
|
|
|
24
|
|
|
protected Quantity $prepaid; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
|
28
|
|
|
protected function setUp(): void |
29
|
|
|
{ |
30
|
|
|
$this->target = new Target('2222', 'overuse,cdn_traf95_max', 'progressive'); |
31
|
|
|
$this->type = new Type('2222', 'cdn_traf95_max'); |
32
|
|
|
$this->prepaid = Quantity::mbps(0); |
33
|
|
|
$this->price = new ProgressivePrice('2222', $this->type, $this->target, $this->prepaid, $this->getThresholds()); |
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
protected function tearDown(): void |
37
|
|
|
{ |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testCalculateUsage() |
41
|
|
|
{ |
42
|
|
|
$this->assertEquals(720, $this->price->calculateUsage(Quantity::mbps(720))->getQuantity()); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testCalculatePrice() |
46
|
|
|
{ |
47
|
|
|
$this->assertSame(json_encode(Money::EUR(594)), json_encode($this->price->calculatePrice(Quantity::mbps(720)))); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testJsonSerialize() |
51
|
|
|
{ |
52
|
|
|
$this->assertSame( |
53
|
|
|
json_encode([ |
54
|
|
|
'id' => '2222', |
55
|
|
|
'type' => [ |
56
|
|
|
'id' => '2222', |
57
|
|
|
'name' => 'cdn_traf95_max', |
58
|
|
|
], |
59
|
|
|
'target' => [ |
60
|
|
|
'id' => '2222', |
61
|
|
|
'type' => 'overuse,cdn_traf95_max', |
62
|
|
|
'name' => 'progressive' |
63
|
|
|
], |
64
|
|
|
'thresholds' => $this->getThresholds(), |
65
|
|
|
'prepaid' => [ |
66
|
|
|
'unit' => 'mbps', |
67
|
|
|
'quantity' => 0, |
68
|
|
|
], |
69
|
|
|
]), |
70
|
|
|
json_encode($this->price)); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
private function getThresholds() |
74
|
|
|
{ |
75
|
|
|
return [ |
76
|
|
|
new ProgressivePriceThresholdsDto(0.0085, new Currency('EUR'), 0), |
77
|
|
|
new ProgressivePriceThresholdsDto(0.0080, new Currency('EUR'), 500), |
78
|
|
|
new ProgressivePriceThresholdsDto(0.0075, new Currency('EUR'), 600), |
79
|
|
|
new ProgressivePriceThresholdsDto(0.0070, new Currency('EUR'), 700), |
80
|
|
|
new ProgressivePriceThresholdsDto(0.0060, new Currency('EUR'), 800), |
81
|
|
|
]; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
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