Completed
Push — master ( f95229...017b93 )
by Nikita
13:15
created

SiteServiceSpec::it_should_get_site()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 3
1
<?php
2
3
namespace spec\Yproximite\Api\Service;
4
5
use PhpSpec\ObjectBehavior;
6
7
use Yproximite\Api\Client\Client;
8
use Yproximite\Api\Model\Site\Site;
9
use Yproximite\Api\Service\SiteService;
10
use Yproximite\Api\Factory\ModelFactory;
11
use Yproximite\Api\Message\Site\SitePostMessage;
12
use Yproximite\Api\Message\Site\PlatformChildrenListMessage;
13
14
class SiteServiceSpec extends ObjectBehavior
15
{
16
    function it_is_initializable()
17
    {
18
        $this->shouldHaveType(SiteService::class);
19
    }
20
21
    function let(Client $client, ModelFactory $factory)
22
    {
23
        $this->beConstructedWith($client, $factory);
24
    }
25
26 View Code Duplication
    function it_should_get_sites(Client $client, ModelFactory $factory)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
27
    {
28
        $method = 'GET';
29
        $path   = 'sites';
30
31
        $client->sendRequest($method, $path)->willReturn([]);
32
        $client->sendRequest($method, $path)->shouldBeCalled();
33
34
        $factory->createMany(Site::class, [])->willReturn([]);
35
36
        $this->getSites();
37
    }
38
39 View Code Duplication
    function it_should_get_site(Client $client, ModelFactory $factory, Site $site)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
40
    {
41
        $method = 'GET';
42
        $path   = 'sites/1';
43
44
        $client->sendRequest($method, $path)->willReturn([]);
45
        $client->sendRequest($method, $path)->shouldBeCalled();
46
47
        $factory->create(Site::class, [])->willReturn($site);
48
49
        $this->getSite(1);
50
    }
51
52
    function it_should_post_site(
53
        Client $client,
54
        ModelFactory $factory,
55
        SitePostMessage $message,
56
        Site $site
57
    ) {
58
        $message->getCompanyId()->willReturn(1);
59
        $message->build()->willReturn([]);
60
61
        $method = 'POST';
62
        $path   = 'sites';
63
        $data   = ['api_site' => []];
64
65
        $client->sendRequest($method, $path, $data)->willReturn([]);
66
        $client->sendRequest($method, $path, $data)->shouldBeCalled();
67
68
        $factory->create(Site::class, [])->willReturn($site);
69
70
        $this->postSite($message);
71
    }
72
73
    function it_should_get_platform_children(
74
        Client $client,
75
        ModelFactory $factory,
76
        PlatformChildrenListMessage $message
77
    ) {
78
        $message->getSiteId()->willReturn(1);
79
        $message->build()->willReturn([]);
80
81
        $method = 'GET';
82
        $path   = 'platform/1/children';
83
84
        $client->sendRequest($method, $path)->willReturn([]);
85
        $client->sendRequest($method, $path)->shouldBeCalled();
86
87
        $factory->createMany(Site::class, [])->willReturn([]);
88
89
        $this->getPlatformChildren($message);
90
    }
91
}
92