Passed
Push — master ( e52344...df819b )
by Rafael
09:21
created

ResponseHelperTrait::dumpResponse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 8
ccs 0
cts 6
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Test;
12
13
use Symfony\Bundle\FrameworkBundle\Client;
14
use Symfony\Component\HttpFoundation\Response;
15
16
/**
17
 * @method Client getClient()
18
 */
19
trait ResponseHelperTrait
20
{
21
    /**
22
     * assertResponseEmptyContent
23
     */
24
    protected static function assertResponseEmptyContent()
25
    {
26
        self::assertEmpty(self::getClient()->getResponse()->getContent());
0 ignored issues
show
Bug Best Practice introduced by
The method Ynlo\GraphQLBundle\Test\...elperTrait::getClient() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        self::assertEmpty(self::/** @scrutinizer ignore-call */ getClient()->getResponse()->getContent());
Loading history...
27
    }
28
29
    /**
30
     * @param string $code
31
     */
32
    protected static function assertResponseCodeIs($code)
33
    {
34
        self::assertEquals($code, self::getClient()->getResponse()->getStatusCode());
0 ignored issues
show
Bug Best Practice introduced by
The method Ynlo\GraphQLBundle\Test\...elperTrait::getClient() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        self::assertEquals($code, self::/** @scrutinizer ignore-call */ getClient()->getResponse()->getStatusCode());
Loading history...
35
    }
36
37
    /**
38
     * assertResponseCodeIsOK
39
     */
40 15
    protected static function assertResponseCodeIsOK()
41
    {
42 15
        self::assertEquals(Response::HTTP_OK, self::getClient()->getResponse()->getStatusCode());
0 ignored issues
show
Bug Best Practice introduced by
The method Ynlo\GraphQLBundle\Test\...elperTrait::getClient() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        self::assertEquals(Response::HTTP_OK, self::/** @scrutinizer ignore-call */ getClient()->getResponse()->getStatusCode());
Loading history...
43 15
    }
44
45
    /**
46
     * @return Response
47
     */
48 21
    protected static function getResponse(): Response
49
    {
50 21
        return self::getClient()->getResponse();
0 ignored issues
show
Bug Best Practice introduced by
The method Ynlo\GraphQLBundle\Test\...elperTrait::getClient() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
        return self::/** @scrutinizer ignore-call */ getClient()->getResponse();
Loading history...
Bug Best Practice introduced by
The expression return self::getClient()->getResponse() could return the type null which is incompatible with the type-hinted return Symfony\Component\HttpFoundation\Response. Consider adding an additional type-check to rule them out.
Loading history...
51
    }
52
}
53