|
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\Addressing\Model; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\Common\Collections\Collection; |
|
17
|
|
|
use PhpSpec\ObjectBehavior; |
|
18
|
|
|
use Sylius\Component\Addressing\Model\Country; |
|
19
|
|
|
use Sylius\Component\Addressing\Model\CountryInterface; |
|
20
|
|
|
use Sylius\Component\Addressing\Model\ProvinceInterface; |
|
21
|
|
|
use Sylius\Component\Resource\Model\CodeAwareInterface; |
|
22
|
|
|
use Sylius\Component\Resource\Model\ToggleableInterface; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
|
26
|
|
|
* @author Gonzalo Vilaseca <[email protected]> |
|
27
|
|
|
* @author Gustavo Perdomo <[email protected]> |
|
28
|
|
|
*/ |
|
29
|
|
|
final class CountrySpec extends ObjectBehavior |
|
30
|
|
|
{ |
|
31
|
|
|
function it_is_initializable(): void |
|
32
|
|
|
{ |
|
33
|
|
|
$this->shouldHaveType(Country::class); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
function it_implements_Sylius_country_interface(): void |
|
|
|
|
|
|
37
|
|
|
{ |
|
38
|
|
|
$this->shouldImplement(CountryInterface::class); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
function it_is_toggleable(): void |
|
42
|
|
|
{ |
|
43
|
|
|
$this->shouldImplement(ToggleableInterface::class); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
function it_implements_code_aware_interface(): void |
|
47
|
|
|
{ |
|
48
|
|
|
$this->shouldImplement(CodeAwareInterface::class); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
function it_has_no_id_by_default(): void |
|
52
|
|
|
{ |
|
53
|
|
|
$this->getId()->shouldReturn(null); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
function it_returns_name_when_converted_to_string(): void |
|
57
|
|
|
{ |
|
58
|
|
|
$this->setCode('VE'); |
|
59
|
|
|
$this->__toString()->shouldReturn('Venezuela'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
function it_has_no_code_by_default(): void |
|
63
|
|
|
{ |
|
64
|
|
|
$this->getCode()->shouldReturn(null); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
function its_code_is_mutable(): void |
|
68
|
|
|
{ |
|
69
|
|
|
$this->setCode('MX'); |
|
70
|
|
|
$this->getCode()->shouldReturn('MX'); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
function it_initializes_provinces_collection_by_default(): void |
|
74
|
|
|
{ |
|
75
|
|
|
$this->getProvinces()->shouldHaveType(Collection::class); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
function it_has_no_provinces_by_default(): void |
|
79
|
|
|
{ |
|
80
|
|
|
$this->hasProvinces()->shouldReturn(false); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
function it_adds_province(ProvinceInterface $province): void |
|
84
|
|
|
{ |
|
85
|
|
|
$this->addProvince($province); |
|
86
|
|
|
$this->hasProvince($province)->shouldReturn(true); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
function it_removes_province(ProvinceInterface $province): void |
|
90
|
|
|
{ |
|
91
|
|
|
$this->addProvince($province); |
|
92
|
|
|
$this->hasProvince($province)->shouldReturn(true); |
|
93
|
|
|
|
|
94
|
|
|
$this->removeProvince($province); |
|
95
|
|
|
$this->hasProvince($province)->shouldReturn(false); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
function it_sets_country_on_added_province(ProvinceInterface $province): void |
|
99
|
|
|
{ |
|
100
|
|
|
$province->setCountry($this)->shouldBeCalled(); |
|
101
|
|
|
$this->addProvince($province); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
function it_unsets_country_on_removed_province(ProvinceInterface $province): void |
|
105
|
|
|
{ |
|
106
|
|
|
$this->addProvince($province); |
|
107
|
|
|
$this->hasProvince($province)->shouldReturn(true); |
|
108
|
|
|
|
|
109
|
|
|
$province->setCountry(null)->shouldBeCalled(); |
|
110
|
|
|
|
|
111
|
|
|
$this->removeProvince($province); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
function it_is_enabled_by_default(): void |
|
115
|
|
|
{ |
|
116
|
|
|
$this->isEnabled()->shouldReturn(true); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
function it_can_be_disabled(): void |
|
120
|
|
|
{ |
|
121
|
|
|
$this->disable(); |
|
122
|
|
|
$this->isEnabled()->shouldReturn(false); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
function it_can_be_enabled(): void |
|
126
|
|
|
{ |
|
127
|
|
|
$this->disable(); |
|
128
|
|
|
$this->isEnabled()->shouldReturn(false); |
|
129
|
|
|
|
|
130
|
|
|
$this->enable(); |
|
131
|
|
|
$this->isEnabled()->shouldReturn(true); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
function it_can_set_enabled_value(): void |
|
135
|
|
|
{ |
|
136
|
|
|
$this->setEnabled(false); |
|
137
|
|
|
$this->isEnabled()->shouldReturn(false); |
|
138
|
|
|
|
|
139
|
|
|
$this->setEnabled(true); |
|
140
|
|
|
$this->isEnabled()->shouldReturn(true); |
|
141
|
|
|
|
|
142
|
|
|
$this->setEnabled(false); |
|
143
|
|
|
$this->isEnabled()->shouldReturn(false); |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.