feat: Ajout d'un endpoint getBySlug
This commit is contained in:
parent
504c62c155
commit
30d26f530d
59
tests/Feature/Manga/GetMangaBySlugTest.php
Normal file
59
tests/Feature/Manga/GetMangaBySlugTest.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Feature\Manga;
|
||||
|
||||
use App\Entity\Manga;
|
||||
use App\Factory\MangaFactory;
|
||||
use App\Tests\Feature\AbstractApiTestCase;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Zenstruck\Foundry\Test\Factories;
|
||||
use Zenstruck\Foundry\Test\ResetDatabase;
|
||||
|
||||
class GetMangaBySlugTest extends AbstractApiTestCase
|
||||
{
|
||||
use ResetDatabase, Factories;
|
||||
|
||||
public function testGetMangaBySlugReturnsCorrectManga(): void
|
||||
{
|
||||
// Arrange
|
||||
$manga = MangaFactory::createOne([
|
||||
'title' => 'One Piece',
|
||||
'slug' => 'one-piece',
|
||||
'description' => 'Description',
|
||||
'author' => 'Eiichiro Oda',
|
||||
'publicationYear' => 1997,
|
||||
'genres' => ['Action', 'Adventure'],
|
||||
'status' => 'ongoing',
|
||||
'imageUrl' => 'https://example.com/image.jpg',
|
||||
'rating' => 4.5,
|
||||
'monitored' => true
|
||||
]);
|
||||
|
||||
// Act
|
||||
static::createClient()->request('GET', '/api/mangas/by-slug/one-piece');
|
||||
|
||||
// Assert
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertJsonContains([
|
||||
'id' => (string) $manga->getId(),
|
||||
'title' => 'One Piece',
|
||||
'slug' => 'one-piece',
|
||||
'description' => 'Description',
|
||||
'author' => 'Eiichiro Oda',
|
||||
'publicationYear' => 1997,
|
||||
'genres' => ['Action', 'Adventure'],
|
||||
'status' => 'ongoing',
|
||||
'imageUrl' => 'https://example.com/image.jpg',
|
||||
'rating' => 4.5
|
||||
]);
|
||||
}
|
||||
|
||||
public function testGetMangaBySlugReturns404WhenMangaNotFound(): void
|
||||
{
|
||||
// Act
|
||||
static::createClient()->request('GET', '/api/mangas/by-slug/non-existent-manga');
|
||||
|
||||
// Assert
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user