test set layout browsing
This commit is contained in:
parent
936855efab
commit
eb7ac7d261
8 changed files with 619 additions and 3 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue