Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
50.00% |
4 / 8 |
|
50.00% |
3 / 6 |
CRAP | |
0.00% |
0 / 1 |
| EditRequestDecorator | |
50.00% |
4 / 8 |
|
50.00% |
3 / 6 |
13.12 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| bootstrap | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| getRequest | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| verifyValidResponse | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| shouldDoRequestValidation | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| shouldDoResponseValidation | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\IntegrationTests\Requests; |
| 3 | |
| 4 | use Apie\IntegrationTests\Interfaces\TestApplicationInterface; |
| 5 | use Closure; |
| 6 | use Psr\Http\Message\ResponseInterface; |
| 7 | use Psr\Http\Message\ServerRequestInterface; |
| 8 | |
| 9 | final class EditRequestDecorator implements TestRequestInterface, BootstrapRequestInterface |
| 10 | { |
| 11 | public function __construct( |
| 12 | private TestRequestInterface $internal, |
| 13 | private Closure $callback, |
| 14 | private Closure $verifyValidResponse |
| 15 | ) { |
| 16 | } |
| 17 | |
| 18 | public function bootstrap(TestApplicationInterface $testApplication): void |
| 19 | { |
| 20 | if ($this->internal instanceof BootstrapRequestInterface) { |
| 21 | $this->internal->bootstrap($testApplication); |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | public function getRequest(): ServerRequestInterface |
| 26 | { |
| 27 | $request = $this->internal->getRequest(); |
| 28 | return ($this->callback)($request); |
| 29 | } |
| 30 | |
| 31 | public function verifyValidResponse(ResponseInterface $response): void |
| 32 | { |
| 33 | ($this->verifyValidResponse)($response, $this->internal); |
| 34 | } |
| 35 | |
| 36 | public function shouldDoRequestValidation(): bool |
| 37 | { |
| 38 | return $this->internal->shouldDoRequestValidation(); |
| 39 | } |
| 40 | |
| 41 | public function shouldDoResponseValidation(): bool |
| 42 | { |
| 43 | return $this->internal->shouldDoResponseValidation(); |
| 44 | } |
| 45 | } |