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
|
|
|
namespace spec\Sylius\Component\Addressing\Model; |
13
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
15
|
|
|
use Sylius\Component\Addressing\Model\AddressInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class AddressSpec extends ObjectBehavior |
21
|
|
|
{ |
22
|
|
|
function it_is_initializable() |
23
|
|
|
{ |
24
|
|
|
$this->shouldHaveType('Sylius\Component\Addressing\Model\Address'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
function it_implements_Sylius_address_interface() |
28
|
|
|
{ |
29
|
|
|
$this->shouldImplement(AddressInterface::class); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
function it_has_no_id_by_default() |
33
|
|
|
{ |
34
|
|
|
$this->getId()->shouldReturn(null); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
function it_has_no_first_name_by_default() |
38
|
|
|
{ |
39
|
|
|
$this->getFirstName()->shouldReturn(null); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
function its_first_name_is_mutable() |
43
|
|
|
{ |
44
|
|
|
$this->setFirstName('John'); |
45
|
|
|
$this->getFirstName()->shouldReturn('John'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
function it_has_no_last_name_by_default() |
49
|
|
|
{ |
50
|
|
|
$this->getLastName()->shouldReturn(null); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
function its_last_name_is_mutable() |
54
|
|
|
{ |
55
|
|
|
$this->setLastName('Doe'); |
56
|
|
|
$this->getLastName()->shouldReturn('Doe'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
function it_returns_correct_full_name() |
60
|
|
|
{ |
61
|
|
|
$this->setFirstName('John'); |
62
|
|
|
$this->setLastName('Doe'); |
63
|
|
|
|
64
|
|
|
$this->getFullName()->shouldReturn('John Doe'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
function it_has_no_phone_number_by_default() |
68
|
|
|
{ |
69
|
|
|
$this->getPhoneNumber()->shouldReturn(null); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
function its_phone_number_is_mutable() |
73
|
|
|
{ |
74
|
|
|
$this->setPhoneNumber('+48555123456'); |
75
|
|
|
$this->getPhoneNumber()->shouldReturn('+48555123456'); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
function it_has_no_country_by_default() |
79
|
|
|
{ |
80
|
|
|
$this->getCountryCode()->shouldReturn(null); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
function its_country_code_is_mutable() |
84
|
|
|
{ |
85
|
|
|
$this->setCountryCode('IE'); |
86
|
|
|
$this->getCountryCode()->shouldReturn('IE'); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
function it_allows_to_unset_the_country_code() |
90
|
|
|
{ |
91
|
|
|
$this->setCountryCode('IE'); |
92
|
|
|
$this->getCountryCode()->shouldReturn('IE'); |
93
|
|
|
|
94
|
|
|
$this->setCountryCode(null); |
95
|
|
|
$this->getCountryCode()->shouldReturn(null); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
function it_unsets_the_province_code_when_erasing_country_code() |
99
|
|
|
{ |
100
|
|
|
$this->setCountryCode('IE'); |
101
|
|
|
$this->setProvinceCode('DU'); |
102
|
|
|
|
103
|
|
|
$this->setCountryCode(null); |
104
|
|
|
|
105
|
|
|
$this->getCountryCode()->shouldReturn(null); |
106
|
|
|
$this->getProvinceCode()->shouldReturn(null); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
function it_has_no_province_code_by_default() |
110
|
|
|
{ |
111
|
|
|
$this->getProvinceCode()->shouldReturn(null); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
function it_ignores_province_code_when_there_is_no_country_code() |
115
|
|
|
{ |
116
|
|
|
$this->setCountryCode(null); |
117
|
|
|
$this->setProvinceCode('DU'); |
118
|
|
|
$this->getProvinceCode()->shouldReturn(null); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
function its_province_code_is_mutable() |
122
|
|
|
{ |
123
|
|
|
$this->setCountryCode("IE"); |
124
|
|
|
|
125
|
|
|
$this->setProvinceCode('DU'); |
126
|
|
|
$this->getProvinceCode()->shouldReturn('DU'); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
function it_has_no_company_by_default() |
130
|
|
|
{ |
131
|
|
|
$this->getCompany()->shouldReturn(null); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
function its_company_is_mutable() |
135
|
|
|
{ |
136
|
|
|
$this->setCompany('Foo Ltd.'); |
137
|
|
|
$this->getCompany()->shouldReturn('Foo Ltd.'); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
function it_has_no_street_by_default() |
141
|
|
|
{ |
142
|
|
|
$this->getStreet()->shouldReturn(null); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
function its_street_is_mutable() |
146
|
|
|
{ |
147
|
|
|
$this->setStreet('Foo Street 3/44'); |
148
|
|
|
$this->getStreet()->shouldReturn('Foo Street 3/44'); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
function it_has_no_city_by_default() |
152
|
|
|
{ |
153
|
|
|
$this->getCity()->shouldReturn(null); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
function its_city_is_mutable() |
157
|
|
|
{ |
158
|
|
|
$this->setCity('New York'); |
159
|
|
|
$this->getCity()->shouldReturn('New York'); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
function it_has_no_postcode_by_default() |
163
|
|
|
{ |
164
|
|
|
$this->getPostcode()->shouldReturn(null); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
function its_postcode_is_mutable() |
168
|
|
|
{ |
169
|
|
|
$this->setPostcode('24154'); |
170
|
|
|
$this->getPostcode()->shouldReturn('24154'); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
function its_creation_time_is_initialized_by_default() |
174
|
|
|
{ |
175
|
|
|
$this->getCreatedAt()->shouldHaveType(\DateTime::class); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
function its_last_update_time_is_undefined_by_default() |
179
|
|
|
{ |
180
|
|
|
$this->getUpdatedAt()->shouldReturn(null); |
181
|
|
|
} |
182
|
|
|
} |
183
|
|
|
|