test element child list
This commit is contained in:
parent
d950fe55dd
commit
aa746fe3f0
4 changed files with 137 additions and 15 deletions
|
|
@ -25,7 +25,18 @@ class ElementControllerTest extends TestCase
|
|||
|
||||
public function testShowReturnsElementPayload(): void
|
||||
{
|
||||
$element = $this->createElement('Baderech HaAvodah');
|
||||
$set = $this->createSet(1, 'Baderech');
|
||||
$element = $this->createElement($set, 'Baderech HaAvodah', null);
|
||||
$firstChildElement = $this->createElement(
|
||||
$set,
|
||||
'Avodah Foundations',
|
||||
$element,
|
||||
);
|
||||
$secondChildElement = $this->createElement(
|
||||
$set,
|
||||
'Daily Practice',
|
||||
$element,
|
||||
);
|
||||
|
||||
$response = $this->controller->show($element->getId());
|
||||
|
||||
|
|
@ -33,6 +44,16 @@ class ElementControllerTest extends TestCase
|
|||
$body = json_decode($response->getContent(), true);
|
||||
$this->assertSame($element->getId(), $body['element']['id']);
|
||||
$this->assertSame('Baderech HaAvodah', $body['element']['title']);
|
||||
$this->assertSame([
|
||||
[
|
||||
'id' => $firstChildElement->getId(),
|
||||
'title' => 'Avodah Foundations',
|
||||
],
|
||||
[
|
||||
'id' => $secondChildElement->getId(),
|
||||
'title' => 'Daily Practice',
|
||||
],
|
||||
], $body['childElements']);
|
||||
}
|
||||
|
||||
public function testShowReturns400WhenIdMissing(): void
|
||||
|
|
@ -57,19 +78,25 @@ class ElementControllerTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
private function createElement(string $title): Element
|
||||
private function createSet(int $id, string $name): DomainSet
|
||||
{
|
||||
$set = new DomainSet(
|
||||
id: 1,
|
||||
name: 'Baderech',
|
||||
description: 'Baderech description',
|
||||
return new DomainSet(
|
||||
id: $id,
|
||||
name: $name,
|
||||
description: "$name description",
|
||||
iconImageUrl: '/assets/baderech-icon.png',
|
||||
);
|
||||
}
|
||||
|
||||
private function createElement(
|
||||
DomainSet $set,
|
||||
string $title,
|
||||
?Element $parentElement,
|
||||
): Element {
|
||||
return $this->elementRepo->create(new CreateElementDto(
|
||||
set: $set,
|
||||
title: $title,
|
||||
parentElement: null,
|
||||
parentElement: $parentElement,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue