test level based scheduling
This commit is contained in:
parent
99e1ba051c
commit
a64df64b76
7 changed files with 415 additions and 94 deletions
|
|
@ -8,7 +8,10 @@ use App\Element\CreateElementDto;
|
|||
use App\Element\ElementRepository;
|
||||
use App\Http\Middleware\AuthMiddleware;
|
||||
use App\Set\CreateSetDto;
|
||||
use App\Set\CreateSetLevelDto;
|
||||
use App\Set\Set;
|
||||
use App\Set\SetLevel;
|
||||
use App\Set\SetLevelRepository;
|
||||
use App\Set\SetRepository;
|
||||
use App\Shared\ValueObject\EmailAddress;
|
||||
use App\User\CreateUserDto;
|
||||
|
|
@ -29,28 +32,27 @@ class GetSetLayoutEndpointTest extends TestCase
|
|||
$user = $this->createUser();
|
||||
$set = $this->createSet($user, 'Bible');
|
||||
$repository = app(ElementRepository::class);
|
||||
$bookLevel = $this->createLevel($set, 'book');
|
||||
$portionLevel = $this->createLevel($set, 'portion');
|
||||
$chapterLevel = $this->createLevel($set, 'chapter');
|
||||
$genesis = $repository->create(new CreateElementDto(
|
||||
set: $set,
|
||||
name: 'Genesis',
|
||||
kind: 'book',
|
||||
level: $bookLevel,
|
||||
parentElement: null,
|
||||
));
|
||||
$repository->create(new CreateElementDto(
|
||||
set: $set,
|
||||
name: 'Exodus',
|
||||
kind: 'book',
|
||||
level: $bookLevel,
|
||||
parentElement: null,
|
||||
));
|
||||
$creation = $repository->create(new CreateElementDto(
|
||||
set: $set,
|
||||
name: 'Creation',
|
||||
kind: 'portion',
|
||||
level: $portionLevel,
|
||||
parentElement: $genesis,
|
||||
));
|
||||
$chapter = $repository->create(new CreateElementDto(
|
||||
set: $set,
|
||||
name: 'Chapter 1',
|
||||
kind: 'chapter',
|
||||
level: $chapterLevel,
|
||||
parentElement: $creation,
|
||||
));
|
||||
$this->createSession($user);
|
||||
|
|
@ -62,21 +64,44 @@ class GetSetLayoutEndpointTest extends TestCase
|
|||
'id' => $set->getId(),
|
||||
'name' => 'Bible',
|
||||
],
|
||||
'levels' => [
|
||||
[
|
||||
'id' => $bookLevel->getId(),
|
||||
'kind' => 'book',
|
||||
'depth' => 0,
|
||||
'elementCount' => 2,
|
||||
],
|
||||
[
|
||||
'id' => $portionLevel->getId(),
|
||||
'kind' => 'portion',
|
||||
'depth' => 1,
|
||||
'elementCount' => 1,
|
||||
],
|
||||
[
|
||||
'id' => $chapterLevel->getId(),
|
||||
'kind' => 'chapter',
|
||||
'depth' => 2,
|
||||
'elementCount' => 1,
|
||||
],
|
||||
],
|
||||
'elements' => [
|
||||
[
|
||||
'id' => $genesis->getId(),
|
||||
'name' => 'Genesis',
|
||||
'kind' => 'book',
|
||||
'levelId' => $bookLevel->getId(),
|
||||
'children' => [
|
||||
[
|
||||
'id' => $creation->getId(),
|
||||
'name' => 'Creation',
|
||||
'kind' => 'portion',
|
||||
'levelId' => $portionLevel->getId(),
|
||||
'children' => [
|
||||
[
|
||||
'id' => $chapter->getId(),
|
||||
'name' => 'Chapter 1',
|
||||
'kind' => 'chapter',
|
||||
'levelId' => $chapterLevel->getId(),
|
||||
'children' => [],
|
||||
],
|
||||
],
|
||||
|
|
@ -87,6 +112,7 @@ class GetSetLayoutEndpointTest extends TestCase
|
|||
'id' => $genesis->getId() + 1,
|
||||
'name' => 'Exodus',
|
||||
'kind' => 'book',
|
||||
'levelId' => $bookLevel->getId(),
|
||||
'children' => [],
|
||||
],
|
||||
],
|
||||
|
|
@ -97,6 +123,7 @@ class GetSetLayoutEndpointTest extends TestCase
|
|||
{
|
||||
$user = $this->createUser();
|
||||
$set = $this->createSet($user, 'Empty set');
|
||||
$taskLevel = $this->createLevel($set, 'task');
|
||||
$this->createSession($user);
|
||||
|
||||
$response = $this->credentialedGet("/api/sets/{$set->getId()}");
|
||||
|
|
@ -106,6 +133,12 @@ class GetSetLayoutEndpointTest extends TestCase
|
|||
'id' => $set->getId(),
|
||||
'name' => 'Empty set',
|
||||
],
|
||||
'levels' => [[
|
||||
'id' => $taskLevel->getId(),
|
||||
'kind' => 'task',
|
||||
'depth' => 0,
|
||||
'elementCount' => 0,
|
||||
]],
|
||||
'elements' => [],
|
||||
]);
|
||||
}
|
||||
|
|
@ -147,6 +180,14 @@ class GetSetLayoutEndpointTest extends TestCase
|
|||
));
|
||||
}
|
||||
|
||||
private function createLevel(Set $set, string $kind): SetLevel
|
||||
{
|
||||
return app(SetLevelRepository::class)->create(new CreateSetLevelDto(
|
||||
set: $set,
|
||||
kind: $kind,
|
||||
));
|
||||
}
|
||||
|
||||
private function createSession(User $user): void
|
||||
{
|
||||
$createdAt = new DateTimeImmutable(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue