Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
93.75% |
15 / 16 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| RemoveResourceApiCall | |
93.75% |
15 / 16 |
|
50.00% |
1 / 2 |
4.00 | |
0.00% |
0 / 1 |
| getRequest | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
2 | |||
| verifyValidResponse | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
2.02 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Apie\IntegrationTests\Requests; |
| 4 | |
| 5 | use Apie\Common\IntegrationTestLogger; |
| 6 | use Apie\IntegrationTests\Requests\JsonFields\JsonGetFieldInterface; |
| 7 | use Nyholm\Psr7\ServerRequest; |
| 8 | use PHPUnit\Framework\TestCase; |
| 9 | use Psr\Http\Message\ResponseInterface; |
| 10 | use Psr\Http\Message\ServerRequestInterface; |
| 11 | |
| 12 | class RemoveResourceApiCall extends ActionMethodApiCall |
| 13 | { |
| 14 | public function getRequest(): ServerRequestInterface |
| 15 | { |
| 16 | $data = $this->inputOutput instanceof JsonGetFieldInterface ? $this->inputOutput->getInputValue() : []; |
| 17 | return new ServerRequest( |
| 18 | 'DELETE', |
| 19 | 'http://localhost/api/' . $this->boundedContextId . '/' . $this->url, |
| 20 | [ |
| 21 | 'content-type' => 'application/json', |
| 22 | 'accept' => 'application/json', |
| 23 | ], |
| 24 | json_encode($data) |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | public function verifyValidResponse(ResponseInterface $response): void |
| 29 | { |
| 30 | $body = (string) $response->getBody(); |
| 31 | $statusCode = $response->getStatusCode(); |
| 32 | if ($statusCode === 500) { |
| 33 | IntegrationTestLogger::failTestShowError(); |
| 34 | } |
| 35 | TestCase::assertEquals(204, $statusCode, 'Expect status code 204, got: ' . $body); |
| 36 | TestCase::assertEquals('', $body); |
| 37 | } |
| 38 | } |