test set root ids

This commit is contained in:
Yisroel Baum 2026-05-25 21:41:48 +03:00
parent 070722e013
commit a87c98a729
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -2,6 +2,8 @@
namespace Tests\Feature; namespace Tests\Feature;
use App\Element\CreateElementDto;
use App\Element\ElementRepository;
use App\Set\CreateSetDto; use App\Set\CreateSetDto;
use App\Set\SetRepository; use App\Set\SetRepository;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
@ -14,6 +16,7 @@ class SetsEndpointTest extends TestCase
public function testReturnsAllSets(): void public function testReturnsAllSets(): void
{ {
$setRepository = app(SetRepository::class); $setRepository = app(SetRepository::class);
$elementRepository = app(ElementRepository::class);
$baderechSet = $setRepository->create(new CreateSetDto( $baderechSet = $setRepository->create(new CreateSetDto(
name: 'Baderech HaAvodah', name: 'Baderech HaAvodah',
description: 'Baderech HaAvodah is a way of living', description: 'Baderech HaAvodah is a way of living',
@ -24,6 +27,13 @@ class SetsEndpointTest extends TestCase
description: 'Daily learning for steady growth', description: 'Daily learning for steady growth',
iconImageUrl: '/assets/daily-learning-icon.svg', iconImageUrl: '/assets/daily-learning-icon.svg',
)); ));
$baderechRootElement = $elementRepository->create(
new CreateElementDto(
set: $baderechSet,
title: $baderechSet->getName(),
parentElement: null,
)
);
$response = $this->getJson('/api/sets'); $response = $this->getJson('/api/sets');
@ -35,12 +45,14 @@ class SetsEndpointTest extends TestCase
'name' => $baderechSet->getName(), 'name' => $baderechSet->getName(),
'description' => $baderechSet->getDescription(), 'description' => $baderechSet->getDescription(),
'iconImageUrl' => $baderechSet->getIconImageUrl(), 'iconImageUrl' => $baderechSet->getIconImageUrl(),
'rootElementId' => $baderechRootElement->getId(),
], ],
[ [
'id' => $dailyLearningSet->getId(), 'id' => $dailyLearningSet->getId(),
'name' => $dailyLearningSet->getName(), 'name' => $dailyLearningSet->getName(),
'description' => $dailyLearningSet->getDescription(), 'description' => $dailyLearningSet->getDescription(),
'iconImageUrl' => $dailyLearningSet->getIconImageUrl(), 'iconImageUrl' => $dailyLearningSet->getIconImageUrl(),
'rootElementId' => null,
], ],
], ],
]); ]);