Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
82.35% covered (warning)
82.35%
14 / 17
57.14% covered (warning)
57.14%
4 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
UploadFileWebdavCall
82.35% covered (warning)
82.35%
14 / 17
57.14% covered (warning)
57.14%
4 / 7
8.35
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTestName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getExpectedStatusCode
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 bootstrap
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
2.06
 isFakeDatalayer
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 shouldDoRequestValidation
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRequest
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Apie\IntegrationTests\Requests;
4
5use Apie\Core\BoundedContext\BoundedContextId;
6use Apie\Core\Entities\EntityInterface;
7use Apie\Core\Identifiers\SnakeCaseSlug;
8use Apie\Faker\Datalayers\FakerDatalayer;
9use Apie\IntegrationTests\Concerns\TestsDefaultWebdavXml;
10use Apie\IntegrationTests\Interfaces\TestApplicationInterface;
11use Nyholm\Psr7\ServerRequest;
12use Psr\Http\Message\ServerRequestInterface;
13
14class UploadFileWebdavCall implements WebdavTestRequestInterface, BootstrapRequestInterface
15{
16    use TestsDefaultWebdavXml;
17    
18    private bool $faked = false;
19
20    /**
21     * @param array<int, EntityInterface> $entities
22     */
23    public function __construct(
24        private readonly BoundedContextId $boundedContextId,
25        private readonly array $entities = [],
26    ) {
27    }
28
29    public function getTestName(): SnakeCaseSlug
30    {
31        return new SnakeCaseSlug('upload_file_in_' . $this->boundedContextId);
32    }
33
34    public function getExpectedStatusCode(): int
35    {
36        return 403;
37    }
38
39    public function bootstrap(TestApplicationInterface $testApplication): void
40    {
41        $apieFacade = $testApplication->getServiceContainer()->get('apie');
42        foreach ($this->entities as $entity) {
43            $apieFacade->persistNew($entity, $this->boundedContextId);
44        }
45        $this->faked = $testApplication->getApplicationConfig()->getDatalayerImplementation()->name === FakerDatalayer::class;
46    }
47
48    public function isFakeDatalayer(): bool
49    {
50        return $this->faked;
51    }
52
53    public function shouldDoRequestValidation(): bool
54    {
55        return false;
56    }
57
58    public function getRequest(): ServerRequestInterface
59    {
60        return new ServerRequest(
61            'PUT',
62            'http://localhost/webdav/' . $this->boundedContextId . '/test.txt',
63            [
64                'Content-Type'  => 'application/octet-stream',
65            ],
66            'This is the content of the uploaded file.'
67        );
68    }
69}