ChangeDirectorySpec::it_should_set_name()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 4
1
<?php
2
3
namespace spec\Akeneo\Crowdin\Api;
4
5
use Akeneo\Crowdin\Client;
6
use GuzzleHttp\Client as HttpClient;
7
use GuzzleHttp\PrepareBodyMiddleware;
8
use GuzzleHttp\Psr7\Request;
9
use GuzzleHttp\Psr7\Response;
10
use PhpSpec\ObjectBehavior;
11
use Prophecy\Argument;
12
13
class ChangeDirectorySpec extends ObjectBehavior
14
{
15
    public function let(Client $client, HttpClient $http)
16
    {
17
        $client->getHttpClient()->willReturn($http);
18
        $client->getProjectIdentifier()->willReturn('sylius');
19
        $client->getProjectApiKey()->willReturn('1234');
20
        $this->beConstructedWith($client);
21
    }
22
23
    public function it_should_be_an_api()
24
    {
25
        $this->shouldBeAnInstanceOf('Akeneo\Crowdin\Api\AbstractApi');
26
    }
27
28
    public function it_should_have_a_name()
29
    {
30
        $this->shouldThrow('\InvalidArgumentException')->during('execute', []);
31
    }
32
33
    public function it_should_set_name(
34
        $http,
35
        Request $request,
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
        Response $response,
37
        PrepareBodyMiddleware $body
38
    ) {
39
        $this->setName('myname');
40
        $path = 'project/sylius/change-directory?key=1234';
41
        $data = ['form_params' => ['name' => 'myname']];
42
        $http->post($path, $data)->willReturn($response);
43
        $response->getBody(Argument::any())->willReturn($body);
44
45
        $this->execute()->shouldReturn($body);
46
    }
47
48
    public function it_should_set_data(
49
        $http,
50
        Request $request,
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
51
        Response $response,
52
        PrepareBodyMiddleware $body
53
    ) {
54
        $this->setName('myName');
55
        $this->setBranch('myBranch');
56
        $this->setExportPattern('myExportPattern');
57
        $this->setTitle('myTitle');
58
        $this->setNewName('myNewName');
59
        $path = 'project/sylius/change-directory?key=1234';
60
        $data = ['form_params' => [
61
            'name'           => 'myName',
62
            'branch'         => 'myBranch',
63
            'export_pattern' => 'myExportPattern',
64
            'title'          => 'myTitle',
65
            'new_name'       => 'myNewName'
66
        ]];
67
        $http->post($path, $data)->willReturn($response);
68
        $response->getBody()->willReturn($body);
69
70
        $this->execute()->shouldReturn($body);
71
    }
72
}
73