mangadexClient = new InMemoryMangadexClient(); $this->mangaRepository = new InMemoryMangaRepository(); $this->handler = new FetchMangaChaptersHandler( $this->mangadexClient, $this->mangaRepository ); } public function testHandleWithExistingManga(): void { $externalId = 'manga-123'; $manga = new Manga( new MangaId('manga-id'), new MangaTitle('Test Manga'), new MangaSlug('test-manga'), 'Description', 'Author', 2024, [], 'ongoing', new ExternalId($externalId) ); $this->mangaRepository->save($manga); $this->mangadexClient->addFeed($externalId, [ [ 'id' => 'chapter-1', 'attributes' => [ 'chapter' => '1', 'title' => 'Chapter 1', 'volume' => '1', 'translatedLanguage' => 'fr' ] ] ]); $command = new FetchMangaChapters($externalId); $this->handler->handle($command); $this->assertCount(1, $this->mangaRepository->getSavedChapters()); } public function testHandleWithNonExistingManga(): void { $externalId = 'non-existing-manga'; $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Manga not found'); $command = new FetchMangaChapters($externalId); $this->handler->handle($command); } }