Completed
Pull Request — dev (#24)
by
unknown
03:54
created

SurveyControllerTest::testSurveys()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 11
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 6
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
    public function testSurveys()
10
    {
11
        $client = static::createClient();
12
13
        $client->request('GET', '/surveys', array(), array(), array(
14
            'PHP_AUTH_USER' => '[email protected]',
15
            'PHP_AUTH_PW' => 'admin',
16
        ));
17
18
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
19
    }
20
21 View Code Duplication
    public function testSurvey()
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...
22
    {
23
        $client = static::createClient();
24
25
        $crawler = $client->request('GET', '/survey/1', array(), array(), array(
26
            'PHP_AUTH_USER' => '[email protected]',
27
            'PHP_AUTH_PW' => 'admin',
28
        ));
29
30
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
31
32
        $this->assertEquals(1, $crawler
33
            ->filter('h3:contains("Internship survey")')
34
            ->count());
35
    }
36
37 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...
38
    {
39
        $client = static::createClient();
40
41
        $crawler = $client->request('GET', '/survey/create/internship', array(), array(), array(
42
            'PHP_AUTH_USER' => '[email protected]',
43
            'PHP_AUTH_PW' => 'admin',
44
        ));
45
46
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
47
48
        $form = $crawler->selectButton('Create survey')->form();
49
50
        $form['survey[user]']->select('3');
51
52
        $client->submit($form);
53
        $client->followRedirects();
54
55
        $this->assertTrue(
56
            $client->getResponse()->isRedirect('/'),
57
            'response is a redirect to homepage'
58
        );
59
    }
60
61 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...
62
    {
63
        $client = static::createClient();
64
65
        $crawler = $client->request('GET', '/survey/delete/4', array(), array(), array(
66
            'PHP_AUTH_USER' => '[email protected]',
67
            'PHP_AUTH_PW' => 'admin',
68
        ));
69
70
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
71
72
        $form = $crawler->selectButton('Delete survey')->form();
73
74
        $client->submit($form);
75
        $client->followRedirects();
76
77
        $this->assertTrue(
78
            $client->getResponse()->isRedirect('/'),
79
            'response is a redirect to homepage'
80
        );
81
    }
82
}
83