repository = new InMemoryMangaRepository(); $this->handler = new GetMangaHandler($this->repository); } public function testHandleThrowsExceptionWhenMangaNotFound(): void { $this->expectException(MangaNotFoundException::class); $query = new GetManga('non-existent-id'); $this->handler->handle($query); } public function testHandleReturnsMangaResponse(): void { // Arrange $manga = new Manga( new MangaId('123'), new MangaTitle('One Piece'), new MangaSlug('one-piece'), 'Description test', 'Eiichiro Oda', 1997, ['action', 'adventure'], 'ongoing', new ExternalId('external-123'), 'http://example.com/image.jpg', 4.5 ); $this->repository->save($manga); // Act $query = new GetManga('123'); $response = $this->handler->handle($query); // Assert $this->assertEquals('123', $response->id); $this->assertEquals('One Piece', $response->title); $this->assertEquals('one-piece', $response->slug); $this->assertEquals('Description test', $response->description); $this->assertEquals('Eiichiro Oda', $response->author); $this->assertEquals(1997, $response->publicationYear); $this->assertEquals(['action', 'adventure'], $response->genres); $this->assertEquals('ongoing', $response->status); $this->assertEquals('external-123', $response->externalId); $this->assertEquals('http://example.com/image.jpg', $response->imageUrl); $this->assertEquals(4.5, $response->rating); } protected function tearDown(): void { $this->repository->clear(); } }