Issues (56)

src/TestResponse.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Digitonic\ApiTestSuite;
4
use Illuminate\Foundation\Testing\Assert as PHPUnit;
5
6
class TestResponse extends \Illuminate\Foundation\Testing\TestResponse
7
{
8
    /**
9
     * Assert that the response has the given status code.
10
     *
11
     * @param  int  $status
12
     * @return $this
13
     */
14
    public function assertStatus($status)
15
    {
16
        $actual = $this->getStatusCode();
0 ignored issues
show
The method getStatusCode() does not exist on Digitonic\ApiTestSuite\TestResponse. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

16
        /** @scrutinizer ignore-call */ 
17
        $actual = $this->getStatusCode();
Loading history...
17
18
        PHPUnit::assertTrue(
19
            $actual === $status,
20
            "Expected status code {$status} but received {$actual}. Response content: \n".
21
            print_r($this->responseContent(), true)
22
        );
23
24
        return $this;
25
    }
26
27
    public function responseContent()
28
    {
29
        $content = $this->getContent();
0 ignored issues
show
The method getContent() does not exist on Digitonic\ApiTestSuite\TestResponse. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

29
        /** @scrutinizer ignore-call */ 
30
        $content = $this->getContent();
Loading history...
30
31
        $json = json_decode($content);
32
33
        if (json_last_error() === JSON_ERROR_NONE) {
34
            $content = $json;
35
        }
36
37
        return $content;
38
    }
39
}
40