test element descriptions
This commit is contained in:
parent
a317f24976
commit
f2dc1483dd
6 changed files with 80 additions and 1 deletions
|
|
@ -19,18 +19,24 @@ class ElementTest extends TestCase
|
|||
$rootElement = new Element(
|
||||
id: 1,
|
||||
title: 'Root',
|
||||
description: 'Root description',
|
||||
set: $set,
|
||||
parentElement: null,
|
||||
);
|
||||
$childElement = new Element(
|
||||
id: 2,
|
||||
title: 'Child',
|
||||
description: 'Child description',
|
||||
set: $set,
|
||||
parentElement: $rootElement,
|
||||
);
|
||||
|
||||
$this->assertSame(2, $childElement->getId());
|
||||
$this->assertSame('Child', $childElement->getTitle());
|
||||
$this->assertSame(
|
||||
'Child description',
|
||||
$childElement->getDescription(),
|
||||
);
|
||||
$this->assertSame($set, $childElement->getSet());
|
||||
$this->assertSame($rootElement, $childElement->getParentElement());
|
||||
$this->assertNull($rootElement->getParentElement());
|
||||
|
|
|
|||
|
|
@ -47,11 +47,13 @@ class CreateElementTest extends TestCase
|
|||
$element = $this->createElement->execute(new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Root',
|
||||
description: 'Root description',
|
||||
parentElementId: null,
|
||||
));
|
||||
|
||||
$this->assertInstanceOf(Element::class, $element);
|
||||
$this->assertSame('Root', $element->getTitle());
|
||||
$this->assertSame('Root description', $element->getDescription());
|
||||
$this->assertSame($set->getId(), $element->getSet()->getId());
|
||||
$this->assertNull($element->getParentElement());
|
||||
}
|
||||
|
|
@ -63,6 +65,7 @@ class CreateElementTest extends TestCase
|
|||
new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Root',
|
||||
description: 'Root description',
|
||||
parentElementId: null,
|
||||
)
|
||||
);
|
||||
|
|
@ -71,17 +74,36 @@ class CreateElementTest extends TestCase
|
|||
new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Child',
|
||||
description: 'Child description',
|
||||
parentElementId: $rootElement->getId(),
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame('Child', $childElement->getTitle());
|
||||
$this->assertSame(
|
||||
'Child description',
|
||||
$childElement->getDescription(),
|
||||
);
|
||||
$this->assertSame(
|
||||
$rootElement->getId(),
|
||||
$childElement->getParentElement()->getId(),
|
||||
);
|
||||
}
|
||||
|
||||
public function testCreatesElementWithBlankDescriptionWhenMissing(): void
|
||||
{
|
||||
$set = $this->createSet('Daily learning');
|
||||
|
||||
$element = $this->createElement->execute(new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Root',
|
||||
description: null,
|
||||
parentElementId: null,
|
||||
));
|
||||
|
||||
$this->assertSame('', $element->getDescription());
|
||||
}
|
||||
|
||||
public function testThrowsWhenSetIdMissing(): void
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
|
|
@ -90,6 +112,7 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: null,
|
||||
title: 'Root',
|
||||
description: 'Root description',
|
||||
parentElementId: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -102,6 +125,7 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: 1,
|
||||
title: null,
|
||||
description: 'Root description',
|
||||
parentElementId: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -114,6 +138,7 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: 99,
|
||||
title: 'Root',
|
||||
description: 'Root description',
|
||||
parentElementId: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -130,6 +155,7 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Child',
|
||||
description: 'Child description',
|
||||
parentElementId: 99,
|
||||
));
|
||||
}
|
||||
|
|
@ -140,6 +166,7 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Root',
|
||||
description: 'Root description',
|
||||
parentElementId: null,
|
||||
));
|
||||
|
||||
|
|
@ -151,6 +178,7 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Another root',
|
||||
description: 'Another root description',
|
||||
parentElementId: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -163,6 +191,7 @@ class CreateElementTest extends TestCase
|
|||
new CreateElementRequest(
|
||||
setId: $parentSet->getId(),
|
||||
title: 'Parent root',
|
||||
description: 'Parent root description',
|
||||
parentElementId: null,
|
||||
)
|
||||
);
|
||||
|
|
@ -175,6 +204,7 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: $childSet->getId(),
|
||||
title: 'Invalid child',
|
||||
description: 'Invalid child description',
|
||||
parentElementId: $parentElement->getId(),
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class GetElementTest extends TestCase
|
|||
$element = $this->createElement(
|
||||
$set,
|
||||
'Baderech HaAvodah',
|
||||
'A structured path for growth',
|
||||
null,
|
||||
);
|
||||
|
||||
|
|
@ -41,6 +42,10 @@ class GetElementTest extends TestCase
|
|||
$this->assertInstanceOf(Element::class, $foundElement);
|
||||
$this->assertSame($element->getId(), $foundElement->getId());
|
||||
$this->assertSame('Baderech HaAvodah', $foundElement->getTitle());
|
||||
$this->assertSame(
|
||||
'A structured path for growth',
|
||||
$foundElement->getDescription(),
|
||||
);
|
||||
}
|
||||
|
||||
public function testReturnsDirectChildElements(): void
|
||||
|
|
@ -49,32 +54,38 @@ class GetElementTest extends TestCase
|
|||
$parentElement = $this->createElement(
|
||||
$set,
|
||||
'Baderech HaAvodah',
|
||||
'A structured path for growth',
|
||||
null,
|
||||
);
|
||||
$firstChildElement = $this->createElement(
|
||||
$set,
|
||||
'Avodah Foundations',
|
||||
'Foundations for steady avodah',
|
||||
$parentElement,
|
||||
);
|
||||
$secondChildElement = $this->createElement(
|
||||
$set,
|
||||
'Daily Practice',
|
||||
'Daily practices for growth',
|
||||
$parentElement,
|
||||
);
|
||||
$this->createElement(
|
||||
$set,
|
||||
'Nested Practice',
|
||||
'Nested description',
|
||||
$firstChildElement,
|
||||
);
|
||||
$otherSet = $this->createSet(2, 'Daily Learning');
|
||||
$otherParentElement = $this->createElement(
|
||||
$otherSet,
|
||||
'Other Parent',
|
||||
'Other parent description',
|
||||
null,
|
||||
);
|
||||
$this->createElement(
|
||||
$otherSet,
|
||||
'Other Child',
|
||||
'Other child description',
|
||||
$otherParentElement,
|
||||
);
|
||||
|
||||
|
|
@ -89,11 +100,19 @@ class GetElementTest extends TestCase
|
|||
$childElements[0]->getId(),
|
||||
);
|
||||
$this->assertSame('Avodah Foundations', $childElements[0]->getTitle());
|
||||
$this->assertSame(
|
||||
'Foundations for steady avodah',
|
||||
$childElements[0]->getDescription(),
|
||||
);
|
||||
$this->assertSame(
|
||||
$secondChildElement->getId(),
|
||||
$childElements[1]->getId(),
|
||||
);
|
||||
$this->assertSame('Daily Practice', $childElements[1]->getTitle());
|
||||
$this->assertSame(
|
||||
'Daily practices for growth',
|
||||
$childElements[1]->getDescription(),
|
||||
);
|
||||
}
|
||||
|
||||
public function testThrowsWhenIdMissing(): void
|
||||
|
|
@ -125,11 +144,13 @@ class GetElementTest extends TestCase
|
|||
private function createElement(
|
||||
DomainSet $set,
|
||||
string $title,
|
||||
string $description,
|
||||
?Element $parentElement,
|
||||
): Element {
|
||||
return $this->elementRepo->create(new CreateElementDto(
|
||||
set: $set,
|
||||
title: $title,
|
||||
description: $description,
|
||||
parentElement: $parentElement,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue