digitonic /
api-test-suite
| 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
Bug
introduced
by
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
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 |