IncidentHookControllerTest::testGetActionOK()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 24
rs 8.9713
cc 1
eloc 13
nc 1
nop 0
1
<?php
2
3
namespace IncidentBundle\Tests\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
7
/**
8
 * Class IncidentHookControllerTest
9
 */
10
class IncidentHookControllerTest extends WebTestCase
11
{
12
    /**
13
     * test webhook get action ok
14
     */
15
    public function testGetActionOK()
16
    {
17
        $client = static::createClient();
18
19
        $incidentIdent = 'proc.7.email.check.'.random_bytes(10);
20
21
        $crawler = $client->request(
22
            'GET',
23
            '/webhook/incident/dnnlpwo2cj287189282bbcnjskshewk/'.$incidentIdent
24
        );
25
26
        $responseObj = $this->assertIncidentJsonResValid($client, $crawler);
27
28
        $this->assertStatusOk($responseObj);
29
30
        $crawler = $client->request(
31
            'GET',
32
            '/webhook/incident/dnnlpwo2cj287189282bbcnjskshewk/'.$incidentIdent
33
        );
34
35
        $responseObj = $this->assertIncidentJsonResValid($client, $crawler);
36
37
        $this->assertStatusOk($responseObj);
38
    }
39
40
    /**
41
     * @param $client
42
     * @param $crawler
43
     *
44
     * @return mixed
45
     */
46 View Code Duplication
    protected function assertIncidentJsonResValid($client, $crawler)
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...
47
    {
48
        $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'HTTP STATUS CODE FAIL:');
49
50
        $this->assertJson($crawler->text());
51
52
        $responseObj = json_decode($crawler->text());
53
54
        return $responseObj;
55
    }
56
57
    /**
58
     * @param $responseObj
59
     */
60
    protected function assertStatusOk($responseObj)
61
    {
62
        $this->assertObjectHasAttribute('status', $responseObj);
63
64
        $this->assertEquals('ok', $responseObj->status);
65
    }
66
}
67