Rabbi_Gerzi/backend/tests/Feature/SetsEndpointTest.php

48 lines
1.5 KiB
PHP

<?php
namespace Tests\Feature;
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);
$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',
));
$response = $this->getJson('/api/sets');
$response->assertOk();
$response->assertExactJson([
'sets' => [
[
'id' => $baderechSet->getId(),
'name' => $baderechSet->getName(),
'description' => $baderechSet->getDescription(),
'iconImageUrl' => $baderechSet->getIconImageUrl(),
],
[
'id' => $dailyLearningSet->getId(),
'name' => $dailyLearningSet->getName(),
'description' => $dailyLearningSet->getDescription(),
'iconImageUrl' => $dailyLearningSet->getIconImageUrl(),
],
],
]);
}
}