1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace spec\Sylius\Component\Taxation\Model; |
15
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
17
|
|
|
use Sylius\Component\Taxation\Model\TaxCategoryInterface; |
18
|
|
|
use Sylius\Component\Taxation\Model\TaxRateInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
final class TaxRateSpec extends ObjectBehavior |
24
|
|
|
{ |
25
|
|
|
function it_implements_tax_rate_interface(): void |
26
|
|
|
{ |
27
|
|
|
$this->shouldImplement(TaxRateInterface::class); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
function it_does_not_have_id_by_default(): void |
31
|
|
|
{ |
32
|
|
|
$this->getId()->shouldReturn(null); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
function it_does_not_belong_to_category_by_default(): void |
36
|
|
|
{ |
37
|
|
|
$this->getCategory()->shouldReturn(null); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
function it_allows_assigning_itself_to_category(TaxCategoryInterface $category): void |
41
|
|
|
{ |
42
|
|
|
$this->setCategory($category); |
43
|
|
|
$this->getCategory()->shouldReturn($category); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
function it_allows_detaching_itself_from_category(TaxCategoryInterface $category): void |
47
|
|
|
{ |
48
|
|
|
$this->setCategory($category); |
49
|
|
|
|
50
|
|
|
$this->setCategory(null); |
51
|
|
|
$this->getCategory()->shouldReturn(null); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
function it_is_unnamed_by_default(): void |
55
|
|
|
{ |
56
|
|
|
$this->getName()->shouldReturn(null); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
function its_name_should_be_mutable(): void |
60
|
|
|
{ |
61
|
|
|
$this->setName('Taxable goods'); |
62
|
|
|
$this->getName()->shouldReturn('Taxable goods'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
function it_has_mutable_code(): void |
66
|
|
|
{ |
67
|
|
|
$this->setCode('TR1'); |
68
|
|
|
$this->getCode()->shouldReturn('TR1'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
function it_has_amount_equal_to_0_by_default(): void |
72
|
|
|
{ |
73
|
|
|
$this->getAmount()->shouldReturn(0.00); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
function its_amount_should_be_mutable(): void |
77
|
|
|
{ |
78
|
|
|
$this->setAmount(0.23); |
79
|
|
|
$this->getAmount()->shouldReturn(0.23); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
function it_represents_amount_as_percentage(): void |
83
|
|
|
{ |
84
|
|
|
$this->setAmount(0.23); |
85
|
|
|
$this->getAmountAsPercentage()->shouldReturn(23.00); |
86
|
|
|
|
87
|
|
|
$this->setAmount(0.125); |
88
|
|
|
$this->getAmountAsPercentage()->shouldReturn(12.5); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
function it_is_not_included_in_price_by_default(): void |
92
|
|
|
{ |
93
|
|
|
$this->shouldNotBeIncludedInPrice(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
function its_inclusion_in_price_should_be_mutable(): void |
97
|
|
|
{ |
98
|
|
|
$this->setIncludedInPrice(true); |
99
|
|
|
$this->shouldBeIncludedInPrice(); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
function it_dose_not_have_calculator_defined_by_default(): void |
103
|
|
|
{ |
104
|
|
|
$this->getCalculator()->shouldReturn(null); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
function its_calculator_should_be_mutable(): void |
108
|
|
|
{ |
109
|
|
|
$this->setCalculator('default'); |
110
|
|
|
$this->getCalculator()->shouldReturn('default'); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
function it_initializes_creation_date_by_default(): void |
114
|
|
|
{ |
115
|
|
|
$this->getCreatedAt()->shouldHaveType(\DateTimeInterface::class); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
function it_does_not_have_last_update_date_by_default(): void |
119
|
|
|
{ |
120
|
|
|
$this->getUpdatedAt()->shouldReturn(null); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
function it_has_label(): void |
124
|
|
|
{ |
125
|
|
|
$this->setName('Test tax'); |
126
|
|
|
$this->setAmount(0.23); |
127
|
|
|
|
128
|
|
|
$this->getLabel()->shouldReturn('Test tax (23%)'); |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|