test element endpoint
This commit is contained in:
parent
2e87add96c
commit
f9c92f3206
1 changed files with 41 additions and 0 deletions
41
backend/tests/Feature/ElementsEndpointTest.php
Normal file
41
backend/tests/Feature/ElementsEndpointTest.php
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?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 ElementsEndpointTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
public function testReturnsElementTitle(): void
|
||||||
|
{
|
||||||
|
$setRepository = app(SetRepository::class);
|
||||||
|
$elementRepository = app(ElementRepository::class);
|
||||||
|
$set = $setRepository->create(new CreateSetDto(
|
||||||
|
name: 'Baderech HaAvodah',
|
||||||
|
description: 'A structured path for growth',
|
||||||
|
iconImageUrl: '/assets/baderech-haavodah-icon.png',
|
||||||
|
));
|
||||||
|
$element = $elementRepository->create(new CreateElementDto(
|
||||||
|
set: $set,
|
||||||
|
title: 'Baderech HaAvodah',
|
||||||
|
parentElement: null,
|
||||||
|
));
|
||||||
|
|
||||||
|
$response = $this->getJson("/api/elements/{$element->getId()}");
|
||||||
|
|
||||||
|
$response->assertOk();
|
||||||
|
$response->assertExactJson([
|
||||||
|
'element' => [
|
||||||
|
'id' => $element->getId(),
|
||||||
|
'title' => 'Baderech HaAvodah',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue