add set layout api
This commit is contained in:
parent
eb7ac7d261
commit
4222d4c0a2
16 changed files with 487 additions and 6 deletions
|
|
@ -39,6 +39,20 @@ class FakeElementRepository implements ElementRepository
|
|||
return $element === null ? null : $this->copy($element);
|
||||
}
|
||||
|
||||
public function findBySet(Set $set): array
|
||||
{
|
||||
$elements = array_filter(
|
||||
$this->elements,
|
||||
function (Element $element) use ($set): bool {
|
||||
return $element->getSet()->getId() === $set->getId();
|
||||
},
|
||||
);
|
||||
|
||||
return array_map(function (Element $element): Element {
|
||||
return $this->copy($element);
|
||||
}, array_values($elements));
|
||||
}
|
||||
|
||||
public function findTopLevelBySet(Set $set): array
|
||||
{
|
||||
$elements = array_filter(
|
||||
|
|
|
|||
|
|
@ -26,6 +26,13 @@ class FakeSetRepository implements SetRepository
|
|||
return $this->copy($set);
|
||||
}
|
||||
|
||||
public function find(int $id): ?Set
|
||||
{
|
||||
$set = $this->sets[$id] ?? null;
|
||||
|
||||
return $set === null ? null : $this->copy($set);
|
||||
}
|
||||
|
||||
public function all(): array
|
||||
{
|
||||
$sets = array_values($this->sets);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use App\User\UserRepository;
|
|||
use DateTimeImmutable;
|
||||
use DateTimeZone;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Testing\TestResponse;
|
||||
use Tests\TestCase;
|
||||
|
||||
class GetSetLayoutEndpointTest extends TestCase
|
||||
|
|
@ -160,7 +161,7 @@ class GetSetLayoutEndpointTest extends TestCase
|
|||
));
|
||||
}
|
||||
|
||||
private function credentialedGet(string $uri): \Illuminate\Testing\TestResponse
|
||||
private function credentialedGet(string $uri): TestResponse
|
||||
{
|
||||
return $this->withCredentials()
|
||||
->withUnencryptedCookie(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace Tests\Unit\Set\UseCases;
|
|||
use App\Element\CreateElementDto;
|
||||
use App\Exceptions\NotFoundException;
|
||||
use App\Set\CreateSetDto;
|
||||
use App\Set\UseCases\GetSetLayout\ElementLayoutNode;
|
||||
use App\Set\UseCases\GetSetLayout\GetSetLayout;
|
||||
use App\Shared\ValueObject\EmailAddress;
|
||||
use App\User\User;
|
||||
|
|
@ -124,7 +125,7 @@ class GetSetLayoutTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @param list<\App\Set\UseCases\GetSetLayout\ElementLayoutNode> $nodes
|
||||
* @param list<ElementLayoutNode> $nodes
|
||||
* @return list<string>
|
||||
*/
|
||||
private function nodeNames(array $nodes): array
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue