Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
93.75% covered (success)
93.75%
15 / 16
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
RemoveResourceApiCall
93.75% covered (success)
93.75%
15 / 16
50.00% covered (danger)
50.00%
1 / 2
4.00
0.00% covered (danger)
0.00%
0 / 1
 getRequest
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
2
 verifyValidResponse
83.33% covered (warning)
83.33%
5 / 6
0.00% covered (danger)
0.00%
0 / 1
2.02
1<?php
2
3namespace Apie\IntegrationTests\Requests;
4
5use Apie\Common\IntegrationTestLogger;
6use Apie\IntegrationTests\Requests\JsonFields\JsonGetFieldInterface;
7use Nyholm\Psr7\ServerRequest;
8use PHPUnit\Framework\TestCase;
9use Psr\Http\Message\ResponseInterface;
10use Psr\Http\Message\ServerRequestInterface;
11
12class 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}