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)
147 lines
4.3 KiB
PHP
147 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Feature\Manga;
|
|
|
|
use App\Entity\Chapter;
|
|
use App\Tests\Factory\ChapterFactory;
|
|
use App\Tests\Factory\MangaFactory;
|
|
use App\Tests\Feature\AbstractApiTestCase;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Zenstruck\Foundry\Test\Factories;
|
|
use Zenstruck\Foundry\Test\ResetDatabase;
|
|
|
|
class DownloadVolumeTest extends AbstractApiTestCase
|
|
{
|
|
use ResetDatabase, Factories;
|
|
|
|
public function test_it_downloads_volume_cbz(): void
|
|
{
|
|
// Arrange
|
|
$manga = MangaFactory::createOne([
|
|
'title' => 'One Piece',
|
|
'slug' => 'one-piece'
|
|
]);
|
|
|
|
// Create chapters for volume 1
|
|
ChapterFactory::createMany(3, [
|
|
'manga' => $manga,
|
|
'volume' => 1,
|
|
'visible' => true,
|
|
'cbzPath' => __DIR__ . '/../../Shared/Files/test-chapter.cbz'
|
|
]);
|
|
|
|
$mangaId = $manga->getId();
|
|
|
|
// Act
|
|
static::createClient()->request('GET', "/api/mangas/{$mangaId}/volumes/1/download");
|
|
|
|
// Assert
|
|
$this->assertResponseIsSuccessful();
|
|
$this->assertResponseHeaderSame('Content-Type', 'application/x-cbz');
|
|
$contentDisposition = static::getClient()->getResponse()->headers->get('Content-Disposition');
|
|
$this->assertStringContainsString('attachment; filename=', $contentDisposition);
|
|
$this->assertStringContainsString('one-piece_vol1.cbz', $contentDisposition);
|
|
}
|
|
|
|
public function test_it_returns_404_when_manga_not_found(): void
|
|
{
|
|
// Act
|
|
static::createClient()->request('GET', '/api/mangas/999999/volumes/1/download');
|
|
|
|
// Assert
|
|
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
|
|
}
|
|
|
|
public function test_it_returns_404_when_volume_not_found(): void
|
|
{
|
|
// Arrange
|
|
$manga = MangaFactory::createOne([
|
|
'title' => 'One Piece',
|
|
'slug' => 'one-piece'
|
|
]);
|
|
|
|
$mangaId = $manga->getId();
|
|
|
|
// Act
|
|
static::createClient()->request('GET', "/api/mangas/{$mangaId}/volumes/999/download");
|
|
|
|
// Assert
|
|
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
|
|
}
|
|
|
|
public function test_it_returns_404_when_no_available_chapters_in_volume(): void
|
|
{
|
|
// Arrange
|
|
$manga = MangaFactory::createOne([
|
|
'title' => 'One Piece',
|
|
'slug' => 'one-piece'
|
|
]);
|
|
|
|
// Create chapters for volume 1 but all without CBZ files
|
|
ChapterFactory::createMany(3, [
|
|
'manga' => $manga,
|
|
'volume' => 1,
|
|
'visible' => true,
|
|
'cbzPath' => null // No CBZ files
|
|
]);
|
|
|
|
$mangaId = $manga->getId();
|
|
|
|
// Act
|
|
static::createClient()->request('GET', "/api/mangas/{$mangaId}/volumes/1/download");
|
|
|
|
// Assert
|
|
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
|
|
}
|
|
|
|
public function test_it_only_includes_visible_chapters_with_cbz(): void
|
|
{
|
|
// Arrange
|
|
$manga = MangaFactory::createOne([
|
|
'title' => 'One Piece',
|
|
'slug' => 'one-piece'
|
|
]);
|
|
|
|
// Create a mix of chapters
|
|
ChapterFactory::createOne([
|
|
'manga' => $manga,
|
|
'volume' => 1,
|
|
'number' => 1.0,
|
|
'visible' => true,
|
|
'cbzPath' => __DIR__ . '/../../Shared/Files/test-chapter.cbz'
|
|
]);
|
|
|
|
ChapterFactory::createOne([
|
|
'manga' => $manga,
|
|
'volume' => 1,
|
|
'number' => 2.0,
|
|
'visible' => false, // Soft deleted
|
|
'cbzPath' => __DIR__ . '/../../Shared/Files/test-chapter.cbz'
|
|
]);
|
|
|
|
ChapterFactory::createOne([
|
|
'manga' => $manga,
|
|
'volume' => 1,
|
|
'number' => 3.0,
|
|
'visible' => true,
|
|
'cbzPath' => null // No CBZ
|
|
]);
|
|
|
|
ChapterFactory::createOne([
|
|
'manga' => $manga,
|
|
'volume' => 1,
|
|
'number' => 4.0,
|
|
'visible' => true,
|
|
'cbzPath' => __DIR__ . '/../../Shared/Files/test-chapter.cbz'
|
|
]);
|
|
|
|
$mangaId = $manga->getId();
|
|
|
|
// Act
|
|
static::createClient()->request('GET', "/api/mangas/{$mangaId}/volumes/1/download");
|
|
|
|
// Assert - Should succeed with only 2 chapters (1 and 4)
|
|
$this->assertResponseIsSuccessful();
|
|
}
|
|
}
|