provider = new InMemoryMangaProvider([$manga]); $this->repository = new InMemoryMangaRepository(); $this->imageProcessor = new InMemoryImageProcessor(); $this->handler = new CreateMangaFromMangadexHandler( $this->provider, $this->repository, $this->imageProcessor ); } public function testHandleSuccess(): void { $command = new CreateMangaFromMangadex('external-123'); $this->handler->handle($command); // Assert $savedManga = $this->repository->findById('123'); $this->assertNotNull($savedManga); $this->assertEquals('One Piece', $savedManga->getTitle()->getValue()); $this->assertNotNull($savedManga->getImageUrls()); $this->assertStringStartsWith('/images/full/', $savedManga->getImageUrls()->getFull()); $this->assertStringStartsWith('/images/thumbnails/', $savedManga->getImageUrls()->getThumbnail()); } public function testHandleThrowsExceptionWhenMangaNotFound(): void { // Arrange $command = new CreateMangaFromMangadex('non-existent-id'); // Assert $this->expectException(MangaNotFoundException::class); $this->expectExceptionMessage('Manga not found on Mangadex'); // Act $this->handler->handle($command); } }