1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Yproximite\Api\Model\Location; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
|
7
|
|
|
use Yproximite\Api\Model\Inheritance\InheritanceStatuses; |
8
|
|
|
use Yproximite\Api\Model\Location\Location; |
9
|
|
|
|
10
|
|
|
class LocationSpec extends ObjectBehavior |
11
|
|
|
{ |
12
|
|
|
function it_is_initializable() |
13
|
|
|
{ |
14
|
|
|
$this->shouldHaveType(Location::class); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
View Code Duplication |
function let() |
|
|
|
|
18
|
|
|
{ |
19
|
|
|
$translation = [ |
20
|
|
|
'title' => 'Some location', |
21
|
|
|
'openingHours' => '24/7', |
22
|
|
|
]; |
23
|
|
|
|
24
|
|
|
$data = [ |
25
|
|
|
'id' => '3', |
26
|
|
|
'tel' => '+1 123 456 78 90', |
27
|
|
|
'fax' => '+2 456 111 78 90', |
28
|
|
|
'mail' => '[email protected]', |
29
|
|
|
'address' => '88 St Patrick St', |
30
|
|
|
'postalCode' => 'M5T 1V1', |
31
|
|
|
'town' => 'City', |
32
|
|
|
'latitude' => '43.6527222', |
33
|
|
|
'longitude' => '-79.3918831', |
34
|
|
|
'country' => 'Canada', |
35
|
|
|
'defaultLocation' => 0, |
36
|
|
|
'dataParent' => '11', |
37
|
|
|
'translations' => ['en' => $translation], |
38
|
|
|
'inheritance_status' => 'overridden', |
39
|
|
|
]; |
40
|
|
|
|
41
|
|
|
$this->beConstructedWith($data); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
function it_should_be_hydrated() |
45
|
|
|
{ |
46
|
|
|
$this->getId()->shouldReturn(3); |
47
|
|
|
$this->getTel()->shouldReturn('+1 123 456 78 90'); |
48
|
|
|
$this->getFax()->shouldReturn('+2 456 111 78 90'); |
49
|
|
|
$this->getMail()->shouldReturn('[email protected]'); |
50
|
|
|
$this->getAddress()->shouldReturn('88 St Patrick St'); |
51
|
|
|
$this->getPostalCode()->shouldReturn('M5T 1V1'); |
52
|
|
|
$this->getTown()->shouldReturn('City'); |
53
|
|
|
$this->getLatitude()->shouldReturn('43.6527222'); |
54
|
|
|
$this->getLongitude()->shouldReturn('-79.3918831'); |
55
|
|
|
$this->getCountry()->shouldReturn('Canada'); |
56
|
|
|
$this->isDefaultLocation()->shouldReturn(false); |
57
|
|
|
$this->getDataParentId()->shouldReturn(11); |
58
|
|
|
$this->getTranslations()->shouldHaveCount(1); |
59
|
|
|
$this->getInheritanceStatus()->shouldReturn(InheritanceStatuses::OVERRIDDEN); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.