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

ResponseHelperTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 45.45%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 32
c 0
b 0
f 0
ccs 5
cts 11
cp 0.4545
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A assertResponseCodeIsOK() 0 3 1
A getResponse() 0 3 1
A assertResponseCodeIs() 0 3 1
A assertResponseEmptyContent() 0 3 1
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