Files
Mangarr/tests/Feature/Reader/GetChapterContextTest.php
ext.jeremy.guillot@maxicoffee.domains 5a0888eb28 refactor: supprimer tout le code legacy MVC/Twig/Stimulus
Supprime toutes les couches pré-DDD pour ne garder que l'architecture
hexagonale (src/Domain/), les entités Doctrine et le front Vue.js SPA.

Supprimé :
- src/Controller/ (9 controllers Twig, garde SecurityController)
- src/Service/, src/Message/, src/MessageHandler/ (services et messages legacy)
- src/Manager/, src/Twig/, src/Form/ (UI legacy)
- src/Event/, src/EventListener/, src/EventSubscriber/QueueStatusSubscriber
- src/Client/MangadexClient.php (doublon du Domain)
- src/Interface/, src/Factory/, src/DataFixtures/, src/Scheduler/MainSchedule
- templates/ (tous sauf vue/ et base retiré — SecurityController = pur JSON)
- assets/controllers/ (20 Stimulus controllers), app.js, bootstrap.js, controllers.json

Modifié :
- config/routes.yaml : suppression du chargement des controllers legacy
- config/packages/messenger.yaml : suppression des routes legacy
- config/services.yaml : suppression des bindings legacy + entrées Domain\Import fantômes
- webpack.config.js : suppression entry 'app' et enableStimulusBridge
- src/Entity/Chapter.php : suppression #[Broadcast] (Turbo Streams legacy)

Déplacé :
- src/Factory/*.php → tests/Factory/ (namespace App\Tests\Factory)
2026-03-26 17:00:46 +01:00

83 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Feature\Reader;
use App\Tests\Factory\ChapterFactory;
use App\Tests\Factory\MangaFactory;
use App\Tests\Feature\AbstractApiTestCase;
use Zenstruck\Foundry\Test\ResetDatabase;
final class GetChapterContextTest extends AbstractApiTestCase
{
use ResetDatabase;
public function testItReturnsChapterContext(): void
{
// Arrange
$manga = MangaFactory::createOne([
'slug' => 'manga-1',
]);
$chapter1 = ChapterFactory::createOne([
'manga' => $manga,
'title' => 'Chapter 1',
'number' => 1,
'visible' => true,
'cbzPath' => '/path/to/chapter1.cbz',
]);
$chapter2 = ChapterFactory::createOne([
'manga' => $manga,
'title' => 'Chapter 2',
'number' => 2,
'visible' => true,
'cbzPath' => '/path/to/chapter2.cbz',
]);
$chapter3 = ChapterFactory::createOne([
'manga' => $manga,
'title' => 'Chapter 3',
'number' => 3,
'visible' => true,
'cbzPath' => '/path/to/chapter3.cbz',
]);
// Act
static::createClient()->request('GET', '/api/reader/chapter/' . $chapter1->getId());
// Assert
$this->assertResponseIsSuccessful();
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
$this->assertJsonContains([
'id' => (string)$chapter1->getId(),
'mangaId' => (string)$manga->getId(),
'title' => 'Chapter 1',
'number' => 1,
'totalPages' => 0,
'navigation' => [
'hydra:member' => [
null, (string)$chapter2->getId(),
],
]
]);
}
public function testItReturns404ForNonExistentChapter(): void
{
// Act
static::createClient()->request('GET', '/api/reader/chapter/0');
// Assert
$this->assertResponseStatusCodeSame(404);
$this->assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
$this->assertJsonContains([
'hydra:title' => 'An error occurred',
'hydra:description' => 'Le chapitre 0 n\'existe pas',
]);
}
}