CompanyServiceSpec::it_should_post_company()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 19
Ratio 100 %

Importance

Changes 0
Metric Value
dl 19
loc 19
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 4
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\Factory\ModelFactory;
9
use Yproximite\Api\Model\Company\Company;
10
use Yproximite\Api\Service\CompanyService;
11
use Yproximite\Api\Message\Company\CompanyPostMessage;
12
use Yproximite\Api\Message\Company\CompanyPatchMessage;
13
14 View Code Duplication
class CompanyServiceSpec extends ObjectBehavior
0 ignored issues
show
Duplication introduced by
This class 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...
15
{
16
    function it_is_initializable()
17
    {
18
        $this->shouldHaveType(CompanyService::class);
19
    }
20
21
    function let(Client $client, ModelFactory $factory)
22
    {
23
        $this->beConstructedWith($client, $factory);
24
    }
25
26
    function it_should_post_company(
27
        Client $client,
28
        ModelFactory $factory,
29
        CompanyPostMessage $message,
30
        Company $company
31
    ) {
32
        $message->build()->willReturn([]);
33
34
        $method = 'POST';
35
        $path   = 'companies';
36
        $data   = ['api_company' => []];
37
38
        $client->sendRequest($method, $path, $data)->willReturn([]);
39
        $client->sendRequest($method, $path, $data)->shouldBeCalled();
40
41
        $factory->create(Company::class, [])->willReturn($company);
42
43
        $this->postCompany($message);
44
    }
45
46
    function it_should_patch_company(
47
        Client $client,
48
        ModelFactory $factory,
49
        CompanyPatchMessage $message,
50
        Company $company
51
    ) {
52
        $message->getId()->willReturn(2);
53
        $message->build()->willReturn([]);
54
55
        $method = 'PATCH';
56
        $path   = 'companies/2';
57
        $data   = ['api_company' => []];
58
59
        $client->sendRequest($method, $path, $data)->willReturn([]);
60
        $client->sendRequest($method, $path, $data)->shouldBeCalled();
61
62
        $factory->create(Company::class, [])->willReturn($company);
63
64
        $this->patchCompany($message);
65
    }
66
}
67