61 lines
2.1 KiB
PHP
61 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Element\CreateElementDto;
|
|
use App\Element\ElementRepository;
|
|
use App\Set\CreateSetDto;
|
|
use App\Set\SetRepository;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class SetsEndpointTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function testReturnsAllSets(): void
|
|
{
|
|
$setRepository = app(SetRepository::class);
|
|
$elementRepository = app(ElementRepository::class);
|
|
$baderechSet = $setRepository->create(new CreateSetDto(
|
|
name: 'Baderech HaAvodah',
|
|
description: 'Baderech HaAvodah is a way of living',
|
|
iconImageUrl: '/assets/baderech-haavodah-icon.png',
|
|
));
|
|
$dailyLearningSet = $setRepository->create(new CreateSetDto(
|
|
name: 'Daily Learning',
|
|
description: 'Daily learning for steady growth',
|
|
iconImageUrl: '/assets/daily-learning-icon.svg',
|
|
));
|
|
$baderechRootElement = $elementRepository->create(
|
|
new CreateElementDto(
|
|
set: $baderechSet,
|
|
title: $baderechSet->getName(),
|
|
description: $baderechSet->getDescription(),
|
|
parentElement: null,
|
|
)
|
|
);
|
|
|
|
$response = $this->getJson('/api/sets');
|
|
|
|
$response->assertOk();
|
|
$response->assertExactJson([
|
|
'sets' => [
|
|
[
|
|
'id' => $baderechSet->getId(),
|
|
'name' => $baderechSet->getName(),
|
|
'description' => $baderechSet->getDescription(),
|
|
'iconImageUrl' => $baderechSet->getIconImageUrl(),
|
|
'rootElementId' => $baderechRootElement->getId(),
|
|
],
|
|
[
|
|
'id' => $dailyLearningSet->getId(),
|
|
'name' => $dailyLearningSet->getName(),
|
|
'description' => $dailyLearningSet->getDescription(),
|
|
'iconImageUrl' => $dailyLearningSet->getIconImageUrl(),
|
|
'rootElementId' => null,
|
|
],
|
|
],
|
|
]);
|
|
}
|
|
}
|