client = static::createClient(); $this->em = static::getContainer()->get(EntityManagerInterface::class); // Démarre une transaction pour pouvoir annuler les modifications des tests $this->em->getConnection()->beginTransaction(); } protected function tearDown(): void { // Rollback la transaction pour annuler les changements des tests $this->em->getConnection()->rollBack(); parent::tearDown(); } public function testReproduceEmoji(): void { $emoji1 = (new Emoji()) ->setCode('😀') ->setName('Parent1') ->setStrength(1.0) ->setToughness(1.0) ->setIntelligence(1.0) ->setSpeed(1.0) ->setFightsWon(5); $emoji2 = (new Emoji()) ->setCode('😎') ->setName('Parent2') ->setStrength(2.0) ->setToughness(2.0) ->setIntelligence(2.0) ->setSpeed(2.0) ->setFightsWon(3); $rarity = (new Rarity()) ->setName('Rare') ->setDropRate(1.0); $this->em->persist($rarity); $this->em->persist($emoji1); $this->em->persist($emoji2); $this->em->flush(); $id1 = $emoji1->getId(); $id2 = $emoji2->getId(); $this->client->request('GET', "/emoji/fusion/$id1/$id2"); $response = $this->client->getResponse(); $this->assertEquals(Response::HTTP_OK, $response->getStatusCode()); $data = json_decode($response->getContent(), true); $this->assertArrayHasKey('childId', $data); $this->assertEquals('Child created', $data['message']); } public function testFusionEmojiNotFound(): void { $emojiRepo = $this->createMock(EmojiRepository::class); $emojiRepo->method('find')->willReturn(null); $this->client->request('GET', '/emoji/fusion/999/998'); $response = $this->client->getResponse(); $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode()); $data = json_decode($response->getContent(), true); $this->assertEquals('One or both emojis not found', $data['error']); } }