Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
89.47% covered (warning)
89.47%
17 / 19
71.43% covered (warning)
71.43%
5 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
ListFilesWebdavCall
89.47% covered (warning)
89.47%
17 / 19
71.43% covered (warning)
71.43%
5 / 7
9.09
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%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 bootstrap
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
 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%
7 / 7
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
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 ListFilesWebdavCall 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 int $depth = 1,
26        private readonly string $pathSuffix = '',
27        private readonly array $entities = [],
28    ) {
29    }
30
31    public function getTestName(): SnakeCaseSlug
32    {
33        return new SnakeCaseSlug(
34            'list_files_in_' . $this->boundedContextId . '_with_depth_' . $this->depth . '_' . count($this->entities) . ($this->pathSuffix ? ('_' . md5($this->pathSuffix)) : '')
35        );
36    }
37
38    public function bootstrap(TestApplicationInterface $testApplication): void
39    {
40        $apieFacade = $testApplication->getServiceContainer()->get('apie');
41        foreach ($this->entities as $entity) {
42            $apieFacade->persistNew($entity, $this->boundedContextId);
43            usleep(1); // Ensure different timestamps
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    
59    public function getRequest(): ServerRequestInterface
60    {
61        return new ServerRequest(
62            'PROPFIND',
63            'http://localhost/webdav/' . $this->boundedContextId . $this->pathSuffix,
64            [
65                'depth' => $this->depth,
66            ]
67        );
68    }
69
70    public function getExpectedStatusCode(): int
71    {
72        return 207;
73    }
74
75}