Completed
Pull Request — master (#30)
by
unknown
05:34
created

SurveyControllerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 61.9 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
c 4
b 0
f 0
lcom 1
cbo 2
dl 39
loc 63
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSurvey() 0 19 1
A testSurveyCreate() 20 20 1
A testSurveyDelete() 19 19 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 Tests\AppBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
7
class SurveyControllerTest extends WebTestCase
8
{
9
    public function testSurvey()
10
    {
11
        exec('./bin/console d:d:c --env=test');
12
        exec('./bin/console d:s:c --env=test');
13
        exec('./bin/console h:f:l -n --env=test');
14
15
        $client = static::createClient();
16
17
        $crawler = $client->request('GET', '/surveys/1', array(), array(), array(
18
            'PHP_AUTH_USER' => '[email protected]',
19
            'PHP_AUTH_PW' => 'admin',
20
        ));
21
22
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
23
24
        $this->assertEquals(1, $crawler
25
            ->filter('h3:contains("Internship survey")')
26
            ->count());
27
    }
28
29 View Code Duplication
    public function testSurveyCreate()
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...
30
    {
31
        $client = static::createClient();
32
33
        $crawler = $client->request('GET', '/surveys/create/internship', array(), array(), array(
34
            'PHP_AUTH_USER' => '[email protected]',
35
            'PHP_AUTH_PW' => 'admin',
36
        ));
37
38
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
39
40
        $form = $crawler->selectButton('Create survey')->form();
41
42
        $form['survey[user]']->select('2');
43
44
        $client->followRedirects();
45
        $client->submit($form);
46
47
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
48
    }
49
50 View Code Duplication
    public function testSurveyDelete()
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...
51
    {
52
        $client = static::createClient();
53
54
        $crawler = $client->request('GET', '/surveys/delete/1', array(), array(), array(
55
            'PHP_AUTH_USER' => '[email protected]',
56
            'PHP_AUTH_PW' => 'admin',
57
        ));
58
59
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
60
61
        $form = $crawler->selectButton('Delete survey')->form();
62
63
        $client->followRedirects();
64
        $client->submit($form);
65
66
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
67
        exec('./bin/console d:d:d --force --env=test');
68
    }
69
}
70