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

SurveyControllerTest::testApiSurveyUpdate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 20
Ratio 100 %

Importance

Changes 0
Metric Value
dl 20
loc 20
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 0
1
<?php
2
3
namespace Tests\AppBundle\Controller\Api;
4
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
7
class SurveyControllerTest extends WebTestCase
8
{
9 View Code Duplication
    public function testApiSurveys()
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
        $client = static::createClient();
12
13
        $client->request('GET', '/api/surveys');
14
15
        $this->assertEquals(401, $client->getResponse()->getStatusCode());
16
17
        $client->request(
18
            'GET',
19
            '/api/surveys',
20
            array(),
21
            array(),
22
            array('HTTP_X-AUTH-TOKEN' => '1')
23
24
        );
25
        $this->assertTrue(
26
            $client->getResponse()->headers->contains(
27
                'Content-Type',
28
                'application/json'
29
            ),
30
            'the "Content-Type" header is "application/json"'
31
        );
32
        $this->assertTrue($client->getResponse()->isSuccessful(), 'response status is 2xx');
33
    }
34
35 View Code Duplication
    public function testApiSurvey()
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...
36
    {
37
        $client = static::createClient();
38
39
        $client->request('GET', '/api/survey/1');
40
41
        $this->assertEquals(401, $client->getResponse()->getStatusCode());
42
43
        $client->request(
44
            'GET',
45
            '/api/surveys',
46
            array(),
47
            array(),
48
            array('HTTP_X-AUTH-TOKEN' => '1')
49
50
        );
51
        $this->assertTrue(
52
            $client->getResponse()->headers->contains(
53
                'Content-Type',
54
                'application/json'
55
            ),
56
            'the "Content-Type" header is "application/json"'
57
        );
58
        $this->assertTrue($client->getResponse()->isSuccessful(), 'response status is 2xx');
59
    }
60
61 View Code Duplication
    public function testApiSurveyUpdate()
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
        $client->request('POST', '/api/survey/update/3');
66
67
        $this->assertEquals(401, $client->getResponse()->getStatusCode());
68
69
        $client->request(
70
            'POST',
71
            '/api/survey/update/3',
72
            array(),
73
            array(),
74
            array('CONTENT_TYPE' => 'application/json',
75
                  'HTTP_X-AUTH-TOKEN' => '1', ),
76
            $content = '{"3":"yes"}'
77
        );
78
79
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
80
    }
81
}
82