Completed
Push — dev ( 388e34...f2f899 )
by nonanerz
04:54 queued 04:49
created

SurveyControllerTest::testSurveys()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 14

Duplication

Lines 21
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 21
loc 21
rs 9.3142
cc 1
eloc 14
nc 1
nop 0
1
<?php
2
3
namespace Tests\AppBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
7
class SurveyControllerTest extends WebTestCase
8
{
9 View Code Duplication
    public function testSurveys()
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...
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', array(), array(), array(
18
            'PHP_AUTH_USER' => '[email protected]',
19
            'PHP_AUTH_PW' => 'admin',
20
        ));
21
22
        $form = $crawler->selectButton('Filter')->form();
23
        $form['survey_filter[type]']->select('1');
24
25
        $client->followRedirects();
26
        $crawler = $client->submit($form);
27
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
28
        $this->assertCount(1, $crawler->filter('ul.survey_item'));
29
    }
30
31
    public function testSurvey()
32
    {
33
        $client = static::createClient();
34
35
        $crawler = $client->request('GET', '/surveys/1', array(), array(), array(
36
            'PHP_AUTH_USER' => '[email protected]',
37
            'PHP_AUTH_PW' => 'admin',
38
        ));
39
40
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
41
42
        $this->assertEquals(1, $crawler
43
            ->filter('h3:contains("Internship survey")')
44
            ->count());
45
    }
46
47 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...
48
    {
49
        $client = static::createClient();
50
51
        $crawler = $client->request('GET', '/surveys/create/internship', array(), array(), array(
52
            'PHP_AUTH_USER' => '[email protected]',
53
            'PHP_AUTH_PW' => 'admin',
54
        ));
55
56
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
57
58
        $form = $crawler->selectButton('Create survey')->form();
59
60
        $form['survey[user]']->select('2');
61
62
        $client->followRedirects();
63
        $client->submit($form);
64
65
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
66
    }
67
68 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...
69
    {
70
        $client = static::createClient();
71
72
        $crawler = $client->request('GET', '/surveys/delete/1', array(), array(), array(
73
            'PHP_AUTH_USER' => '[email protected]',
74
            'PHP_AUTH_PW' => 'admin',
75
        ));
76
77
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
78
79
        $form = $crawler->selectButton('Delete survey')->form();
80
81
        $client->followRedirects();
82
        $client->submit($form);
83
84
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
85
        exec('./bin/console d:d:d --force --env=test');
86
    }
87
}
88