test set layout browsing

This commit is contained in:
Yisroel Baum 2026-08-08 23:30:11 +03:00
parent 936855efab
commit eb7ac7d261
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
8 changed files with 619 additions and 3 deletions

View file

@ -156,6 +156,45 @@ class EloquentElementRepositoryTest extends TestCase
);
}
public function testItListsEveryElementForASet(): void
{
$bible = $this->createSet('Bible');
$course = $this->createSet('Course');
$repository = app(ElementRepository::class);
$genesis = $repository->create(new CreateElementDto(
set: $bible,
name: 'Genesis',
kind: 'book',
parentElement: null,
));
$repository->create(new CreateElementDto(
set: $bible,
name: 'Creation',
kind: 'portion',
parentElement: $genesis,
));
$repository->create(new CreateElementDto(
set: $course,
name: 'Foundations',
kind: 'module',
parentElement: null,
));
$elements = $repository->findBySet($bible);
$this->assertSame(
['Genesis', 'Creation'],
array_map(function ($element): string {
return $element->getName();
}, $elements),
);
$this->assertNull($elements[0]->getParentElement());
$this->assertSame(
$genesis->getId(),
$elements[1]->getParentElement()?->getId(),
);
}
private function createSet(string $name): Set
{
$creator = app(UserRepository::class)->create(new CreateUserDto(