add set media fields
This commit is contained in:
parent
1ce7688d33
commit
fa8efd765f
10 changed files with 61 additions and 21 deletions
|
|
@ -7,6 +7,7 @@ use App\Element\UseCases\CreateElement\CreateElement;
|
|||
use App\Element\UseCases\CreateElement\CreateElementRequest;
|
||||
use App\Exceptions\BadRequestException;
|
||||
use App\Set\CreateSetDto;
|
||||
use App\Set\Set as DomainSet;
|
||||
use DomainException;
|
||||
use Tests\Fakes\FakeElementRepository;
|
||||
use Tests\Fakes\FakeSetRepository;
|
||||
|
|
@ -30,11 +31,18 @@ class CreateElementTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
private function createSet(string $name): DomainSet
|
||||
{
|
||||
return $this->setRepo->create(new CreateSetDto(
|
||||
name: $name,
|
||||
description: "$name description",
|
||||
iconImageUrl: '/assets/test-set-icon.svg',
|
||||
));
|
||||
}
|
||||
|
||||
public function testCreatesRootElement(): void
|
||||
{
|
||||
$set = $this->setRepo->create(
|
||||
new CreateSetDto('Daily learning')
|
||||
);
|
||||
$set = $this->createSet('Daily learning');
|
||||
|
||||
$element = $this->createElement->execute(new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
|
|
@ -50,9 +58,7 @@ class CreateElementTest extends TestCase
|
|||
|
||||
public function testCreatesChildElement(): void
|
||||
{
|
||||
$set = $this->setRepo->create(
|
||||
new CreateSetDto('Daily learning')
|
||||
);
|
||||
$set = $this->createSet('Daily learning');
|
||||
$rootElement = $this->createElement->execute(
|
||||
new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
|
|
@ -114,9 +120,7 @@ class CreateElementTest extends TestCase
|
|||
|
||||
public function testThrowsWhenParentElementDoesNotExist(): void
|
||||
{
|
||||
$set = $this->setRepo->create(
|
||||
new CreateSetDto('Daily learning')
|
||||
);
|
||||
$set = $this->createSet('Daily learning');
|
||||
|
||||
$this->expectException(DomainException::class);
|
||||
$this->expectExceptionMessage(
|
||||
|
|
@ -132,9 +136,7 @@ class CreateElementTest extends TestCase
|
|||
|
||||
public function testThrowsWhenRootElementAlreadyExists(): void
|
||||
{
|
||||
$set = $this->setRepo->create(
|
||||
new CreateSetDto('Daily learning')
|
||||
);
|
||||
$set = $this->createSet('Daily learning');
|
||||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Root',
|
||||
|
|
@ -155,12 +157,8 @@ class CreateElementTest extends TestCase
|
|||
|
||||
public function testThrowsWhenParentBelongsToAnotherSet(): void
|
||||
{
|
||||
$parentSet = $this->setRepo->create(
|
||||
new CreateSetDto('Parent set')
|
||||
);
|
||||
$childSet = $this->setRepo->create(
|
||||
new CreateSetDto('Child set')
|
||||
);
|
||||
$parentSet = $this->createSet('Parent set');
|
||||
$childSet = $this->createSet('Child set');
|
||||
$parentElement = $this->createElement->execute(
|
||||
new CreateElementRequest(
|
||||
setId: $parentSet->getId(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue