Failed Conditions
Push — master ( b9670c...4ba57f )
by Zac
16:20 queued 37s
created

ApiControllerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 25.93 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 2
dl 7
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetAll() 0 16 1
A testGetAllInsufficentPerms() 7 7 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 Overwatch\ExpectationBundle\Tests\Controller;
4
5
use Overwatch\UserBundle\Tests\Base\FunctionalTestCase;
6
use Symfony\Component\HttpFoundation\Response;
7
8
/**
9
 * ApiControllerTest
10
 * Functional test of API method provided by the APIController
11
 */
12
class ApiControllerTest extends FunctionalTestCase
13
{
14
    public function testGetAll()
15
    {
16
        $expectations = [
17
            'toPing',
18
            'toResolveTo',
19
            'toRespondHttp',
20
            'toRespondWithMimeType',
21
            'toContainText',
22
        ];
23
24
        $this->logIn('ROLE_ADMIN');
25
        $this->client->request('GET', '/api/expectations');
26
27
        $this->assertJsonResponse($this->client->getResponse());
28
        $this->assertJsonStringEqualsJsonString(json_encode($expectations), $this->client->getResponse()->getContent());
29
    }
30
31 View Code Duplication
    public function testGetAllInsufficentPerms()
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...
32
    {
33
        $this->logIn('ROLE_USER');
34
        $this->client->request('GET', '/api/expectations');
35
36
        $this->assertEquals(Response::HTTP_FORBIDDEN, $this->client->getResponse()->getStatusCode());
37
    }
38
}
39