refactor(manga): merge ChapterRepositoryInterface into MangaRepositoryInterface + pagesDirectory

- Supprime ChapterRepositoryInterface du domaine Manga (et ses implémentations
  LegacyChapterRepository et InMemoryChapterRepository)
- Déplace toutes les méthodes chapter vers MangaRepositoryInterface avec nommage
  explicite (findChapterById, findVisibleChapterById, updateChapter, deleteChapter, etc.)
- Remplace cbzPath par pagesDirectory + pageCount dans le modèle Chapter
  (transition : toChapterDomain conserve un fallback cbzPath pour les données existantes,
  updateChapter synchronise les deux colonnes jusqu'à la Phase 4)
- Ajoute la migration Doctrine (pages_directory, page_count sur la table chapter)
- Met à jour tous les handlers, listeners, query handlers et state providers du domaine
  Manga pour injecter uniquement MangaRepositoryInterface
- Adapte les tests unitaires et InMemoryMangaRepository avec les nouvelles méthodes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2026-03-09 17:54:35 +01:00
parent dae215dd3d
commit c50f1638ee
27 changed files with 410 additions and 419 deletions

View File

@@ -11,7 +11,6 @@ use App\Domain\Manga\Domain\Model\ValueObject\ChapterId;
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\InMemoryChapterRepository;
use App\Tests\Domain\Manga\Adapter\InMemoryMangaRepository;
use App\Tests\Domain\Manga\Adapter\InMemoryPathManager;
use PHPUnit\Framework\TestCase;
@@ -19,18 +18,15 @@ use PHPUnit\Framework\TestCase;
class ImportVolumeHandlerTest extends TestCase
{
private InMemoryMangaRepository $mangaRepository;
private InMemoryChapterRepository $chapterRepository;
private InMemoryPathManager $pathManager;
private ImportVolumeHandler $handler;
protected function setUp(): void
{
$this->mangaRepository = new InMemoryMangaRepository();
$this->chapterRepository = new InMemoryChapterRepository();
$this->pathManager = new InMemoryPathManager();
$this->handler = new ImportVolumeHandler(
$this->mangaRepository,
$this->chapterRepository,
$this->pathManager
);
}
@@ -63,7 +59,7 @@ class ImportVolumeHandlerTest extends TestCase
true,
null
);
$this->chapterRepository->save($chapter);
$this->mangaRepository->saveChapter($chapter);
}
$cbzBinary = $this->createValidCbzBinary();
@@ -77,12 +73,12 @@ class ImportVolumeHandlerTest extends TestCase
$this->handler->handle($command);
// Assert
$chapters = $this->chapterRepository->findByMangaIdAndVolume($mangaId, $volumeNumber);
$chapters = $this->mangaRepository->findChaptersByMangaIdAndVolume($mangaId, $volumeNumber);
$this->assertCount(3, $chapters);
foreach ($chapters as $chapter) {
$this->assertTrue($chapter->isAvailable());
$this->assertStringContainsString('_vol' . $volumeNumber . '.cbz', $chapter->getCbzPath());
$this->assertNotNull($chapter->getPagesDirectory());
}
}
@@ -153,7 +149,7 @@ class ImportVolumeHandlerTest extends TestCase
$cbzBinary = $this->createValidCbzBinary();
$command = new ImportVolume(
mangaId: $mangaId,
volumeNumber: 999, // Non-existent volume
volumeNumber: 999,
fileBinary: $cbzBinary
);
@@ -165,9 +161,6 @@ class ImportVolumeHandlerTest extends TestCase
$this->handler->handle($command);
}
/**
* Create a minimal valid CBZ (ZIP) binary for testing
*/
private function createValidCbzBinary(): string
{
$tmpFile = tempnam(sys_get_temp_dir(), 'cbz_');
@@ -187,7 +180,3 @@ class ImportVolumeHandlerTest extends TestCase
return $binaryContent;
}
}