fix(import): extraire les images CBZ vers le stockage individuel

Corrige l'import de chapitres/volumes CBZ qui stockait le chemin du fichier
CBZ comme pagesDirectory. Le reader ne trouvait aucune image car
LegacyChapterRepository attend un dossier d'images individuelles.

- Déplace ImageStorageInterface dans Shared (storeChapterImages + extractFromCbz + countCbzImages)
- Crée ImageStorageManager dans Shared/Infrastructure (extraction ZIP + copie)
- Supprime LocalImageStorage et l'ancienne interface dans Scraping
- Refactore ImportChapterHandler et ImportVolumeHandler pour utiliser ImageStorageInterface
- Corrige LegacyChapterRepository : construit l'URL depuis basename(pagesDirectory)
  au lieu de chapterId (fix pour les volumes partagés)
This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2026-03-15 18:26:28 +01:00
parent be8a3c6de8
commit 2e3abb76c3
13 changed files with 173 additions and 108 deletions

View File

@@ -13,22 +13,22 @@ use App\Domain\Manga\Domain\Model\ValueObject\MangaId;
use App\Domain\Manga\Domain\Model\ValueObject\MangaSlug;
use App\Domain\Manga\Domain\Model\ValueObject\MangaTitle;
use App\Tests\Domain\Manga\Adapter\InMemoryMangaRepository;
use App\Tests\Domain\Manga\Adapter\InMemoryPathManager;
use App\Tests\Domain\Scraping\Adapter\InMemoryImageStorage;
use PHPUnit\Framework\TestCase;
class ImportChapterHandlerTest extends TestCase
{
private InMemoryMangaRepository $mangaRepository;
private InMemoryPathManager $pathManager;
private InMemoryImageStorage $imageStorage;
private ImportChapterHandler $handler;
protected function setUp(): void
{
$this->mangaRepository = new InMemoryMangaRepository();
$this->pathManager = new InMemoryPathManager();
$this->imageStorage = new InMemoryImageStorage();
$this->handler = new ImportChapterHandler(
$this->mangaRepository,
$this->pathManager
$this->imageStorage
);
}

View File

@@ -12,22 +12,22 @@ use App\Domain\Manga\Domain\Model\ValueObject\MangaId;
use App\Domain\Manga\Domain\Model\ValueObject\MangaSlug;
use App\Domain\Manga\Domain\Model\ValueObject\MangaTitle;
use App\Tests\Domain\Manga\Adapter\InMemoryMangaRepository;
use App\Tests\Domain\Manga\Adapter\InMemoryPathManager;
use App\Tests\Domain\Scraping\Adapter\InMemoryImageStorage;
use PHPUnit\Framework\TestCase;
class ImportVolumeHandlerTest extends TestCase
{
private InMemoryMangaRepository $mangaRepository;
private InMemoryPathManager $pathManager;
private InMemoryImageStorage $imageStorage;
private ImportVolumeHandler $handler;
protected function setUp(): void
{
$this->mangaRepository = new InMemoryMangaRepository();
$this->pathManager = new InMemoryPathManager();
$this->imageStorage = new InMemoryImageStorage();
$this->handler = new ImportVolumeHandler(
$this->mangaRepository,
$this->pathManager
$this->imageStorage
);
}

View File

@@ -2,18 +2,31 @@
namespace App\Tests\Domain\Scraping\Adapter;
use App\Domain\Scraping\Domain\Contract\Service\ImageStorageInterface;
use App\Domain\Shared\Domain\Contract\ImageStorageInterface;
class InMemoryImageStorage implements ImageStorageInterface
{
/** @var array<string, string> chapterId => pagesDirectory */
/** @var array<string, string> targetId => pagesDirectory */
public array $stored = [];
public function storeChapterImages(string $chapterId, array $localImagePaths): string
public function storeChapterImages(string $targetId, array $localImagePaths): string
{
$dir = '/fake/pages/' . $chapterId;
$this->stored[$chapterId] = $dir;
$dir = '/fake/pages/' . $targetId;
$this->stored[$targetId] = $dir;
return $dir;
}
public function extractFromCbz(string $targetId, string $cbzBinary): string
{
$dir = '/fake/pages/' . $targetId;
$this->stored[$targetId] = $dir;
return $dir;
}
public function countCbzImages(string $cbzBinary): int
{
return 0;
}
}