Completed
Push — pull-request/8715 ( 14a000 )
by Kamil
27:59
created

AddressSpec   A

Complexity

Total Complexity 29

Size/Duplication

Total Lines 174
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 29
lcom 0
cbo 1
dl 0
loc 174
rs 10
c 0
b 0
f 0

29 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_implements_Sylius_address_interface() 0 4 1
A it_has_no_id_by_default() 0 4 1
A it_has_no_first_name_by_default() 0 4 1
A its_first_name_is_mutable() 0 5 1
A it_has_no_last_name_by_default() 0 4 1
A its_last_name_is_mutable() 0 5 1
A it_returns_correct_full_name() 0 7 1
A it_has_no_phone_number_by_default() 0 4 1
A its_phone_number_is_mutable() 0 5 1
A it_has_no_country_by_default() 0 4 1
A its_country_code_is_mutable() 0 5 1
A it_allows_to_unset_the_country_code() 0 8 1
A it_unsets_the_province_code_when_erasing_country_code() 0 10 1
A it_has_no_province_code_by_default() 0 4 1
A it_ignores_province_code_when_there_is_no_country_code() 0 6 1
A its_province_code_is_mutable() 0 7 1
A it_has_no_province_name_by_default() 0 4 1
A its_province_name_is_mutable() 0 5 1
A it_has_no_company_by_default() 0 4 1
A its_company_is_mutable() 0 5 1
A it_has_no_street_by_default() 0 4 1
A its_street_is_mutable() 0 5 1
A it_has_no_city_by_default() 0 4 1
A its_city_is_mutable() 0 5 1
A it_has_no_postcode_by_default() 0 4 1
A its_postcode_is_mutable() 0 5 1
A its_creation_time_is_initialized_by_default() 0 4 1
A its_last_update_time_is_undefined_by_default() 0 4 1
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 PhpSpec\ObjectBehavior;
17
use Sylius\Component\Addressing\Model\Address;
18
use Sylius\Component\Addressing\Model\AddressInterface;
19
20
/**
21
 * @author Paweł Jędrzejewski <[email protected]>
22
 */
23
final class AddressSpec extends ObjectBehavior
24
{
25
    function it_is_initializable(): void
26
    {
27
        $this->shouldHaveType(Address::class);
28
    }
29
30
    function it_implements_Sylius_address_interface(): void
0 ignored issues
show
Coding Style introduced by
function it_implements_Sylius_address_interface() does not seem to conform to the naming convention (^(?:(?:[a-z]|__)[a-zA-Z0-9]*|[a-z][a-z0-9_]*)$).

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.

Loading history...
31
    {
32
        $this->shouldImplement(AddressInterface::class);
33
    }
34
35
    function it_has_no_id_by_default(): void
36
    {
37
        $this->getId()->shouldReturn(null);
38
    }
39
40
    function it_has_no_first_name_by_default(): void
41
    {
42
        $this->getFirstName()->shouldReturn(null);
43
    }
44
45
    function its_first_name_is_mutable(): void
46
    {
47
        $this->setFirstName('John');
48
        $this->getFirstName()->shouldReturn('John');
49
    }
50
51
    function it_has_no_last_name_by_default(): void
52
    {
53
        $this->getLastName()->shouldReturn(null);
54
    }
55
56
    function its_last_name_is_mutable(): void
57
    {
58
        $this->setLastName('Doe');
59
        $this->getLastName()->shouldReturn('Doe');
60
    }
61
62
    function it_returns_correct_full_name(): void
63
    {
64
        $this->setFirstName('John');
65
        $this->setLastName('Doe');
66
67
        $this->getFullName()->shouldReturn('John Doe');
68
    }
69
70
    function it_has_no_phone_number_by_default(): void
71
    {
72
        $this->getPhoneNumber()->shouldReturn(null);
73
    }
74
75
    function its_phone_number_is_mutable(): void
76
    {
77
        $this->setPhoneNumber('+48555123456');
78
        $this->getPhoneNumber()->shouldReturn('+48555123456');
79
    }
80
81
    function it_has_no_country_by_default(): void
82
    {
83
        $this->getCountryCode()->shouldReturn(null);
84
    }
85
86
    function its_country_code_is_mutable(): void
87
    {
88
        $this->setCountryCode('IE');
89
        $this->getCountryCode()->shouldReturn('IE');
90
    }
91
92
    function it_allows_to_unset_the_country_code(): void
93
    {
94
        $this->setCountryCode('IE');
95
        $this->getCountryCode()->shouldReturn('IE');
96
97
        $this->setCountryCode(null);
98
        $this->getCountryCode()->shouldReturn(null);
99
    }
100
101
    function it_unsets_the_province_code_when_erasing_country_code(): void
102
    {
103
        $this->setCountryCode('IE');
104
        $this->setProvinceCode('DU');
105
106
        $this->setCountryCode(null);
107
108
        $this->getCountryCode()->shouldReturn(null);
109
        $this->getProvinceCode()->shouldReturn(null);
110
    }
111
112
    function it_has_no_province_code_by_default(): void
113
    {
114
        $this->getProvinceCode()->shouldReturn(null);
115
    }
116
117
    function it_ignores_province_code_when_there_is_no_country_code(): void
118
    {
119
        $this->setCountryCode(null);
120
        $this->setProvinceCode('DU');
121
        $this->getProvinceCode()->shouldReturn(null);
122
    }
123
124
    function its_province_code_is_mutable(): void
125
    {
126
        $this->setCountryCode('IE');
127
128
        $this->setProvinceCode('DU');
129
        $this->getProvinceCode()->shouldReturn('DU');
130
    }
131
132
    function it_has_no_province_name_by_default(): void
133
    {
134
        $this->getProvinceName()->shouldReturn(null);
135
    }
136
137
    function its_province_name_is_mutable(): void
138
    {
139
        $this->setProvinceName('Utah');
140
        $this->getProvinceName()->shouldReturn('Utah');
141
    }
142
143
    function it_has_no_company_by_default(): void
144
    {
145
        $this->getCompany()->shouldReturn(null);
146
    }
147
148
    function its_company_is_mutable(): void
149
    {
150
        $this->setCompany('Foo Ltd.');
151
        $this->getCompany()->shouldReturn('Foo Ltd.');
152
    }
153
154
    function it_has_no_street_by_default(): void
155
    {
156
        $this->getStreet()->shouldReturn(null);
157
    }
158
159
    function its_street_is_mutable(): void
160
    {
161
        $this->setStreet('Foo Street 3/44');
162
        $this->getStreet()->shouldReturn('Foo Street 3/44');
163
    }
164
165
    function it_has_no_city_by_default(): void
166
    {
167
        $this->getCity()->shouldReturn(null);
168
    }
169
170
    function its_city_is_mutable(): void
171
    {
172
        $this->setCity('New York');
173
        $this->getCity()->shouldReturn('New York');
174
    }
175
176
    function it_has_no_postcode_by_default(): void
177
    {
178
        $this->getPostcode()->shouldReturn(null);
179
    }
180
181
    function its_postcode_is_mutable(): void
182
    {
183
        $this->setPostcode('24154');
184
        $this->getPostcode()->shouldReturn('24154');
185
    }
186
187
    function its_creation_time_is_initialized_by_default(): void
188
    {
189
        $this->getCreatedAt()->shouldHaveType(\DateTimeInterface::class);
190
    }
191
192
    function its_last_update_time_is_undefined_by_default(): void
193
    {
194
        $this->getUpdatedAt()->shouldReturn(null);
195
    }
196
}
197