Completed
Push — master ( eb5568...bc1b58 )
by Nicolas
9s
created

DeleteDirectorySpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 5
dl 36
loc 36
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 7 7 1
A it_should_be_an_api() 4 4 1
A it_should_not_delete_with_no_directory() 9 9 1
A it_deletes_a_directory() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace spec\Akeneo\Crowdin\Api;
4
5
use Akeneo\Crowdin\Client;
6
use Guzzle\Http\Client as HttpClient;
7
use Guzzle\Http\Message\Response;
8
use Guzzle\Http\Message\Request;
9
use PhpSpec\ObjectBehavior;
10
11 View Code Duplication
class DeleteDirectorySpec 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...
12
{
13
    function let(Client $client, HttpClient $http)
14
    {
15
        $client->getHttpClient()->willReturn($http);
16
        $client->getProjectIdentifier()->willReturn('sylius');
17
        $client->getProjectApiKey()->willReturn('1234');
18
        $this->beConstructedWith($client);
19
    }
20
21
    function it_should_be_an_api()
22
    {
23
        $this->shouldBeAnInstanceOf('Akeneo\Crowdin\Api\AbstractApi');
24
    }
25
26
    function it_should_not_delete_with_no_directory(HttpClient $http, Request $request, Response $response)
27
    {
28
        $content = '<xml></xml>';
29
        $response->getBody(true)->willReturn($content);
30
        $request->send()->willReturn($response);
31
32
        $http->post('project/sylius/delete-directory?key=1234')->willReturn($request);
33
        $this->shouldThrow('\InvalidArgumentException')->duringExecute();
34
    }
35
36
    function it_deletes_a_directory(HttpClient $http, Request $request, Response $response)
37
    {
38
        $this->setDirectory('directory-to-delete');
39
        $content = '<?xml version="1.0" encoding="ISO-8859-1"?><success></success>';
40
        $response->getBody(true)->willReturn($content);
41
        $request->send()->willReturn($response);
42
        $http->post('project/sylius/delete-directory?key=1234', array(), array('name' => 'directory-to-delete'))->willReturn($request);
43
44
        $this->execute()->shouldBe($content);
45
    }
46
}