/** * @return array */ private function prepareAValidGameInDatabase() { $this->createPlayers(['Player_A', 'Player_B', 'Player_C', 'Player_D']); $em = $this->getEntityManager(); $playerA = $em->getRepository('AppBundle:Player')->findOneById(1); $playerB = $em->getRepository('AppBundle:Player')->findOneById(2); $playerC = $em->getRepository('AppBundle:Player')->findOneById(3); $playerD = $em->getRepository('AppBundle:Player')->findOneById(4); $teamA = new Team(); $teamA->setPlayerA($playerA); $teamA->setPlayerB($playerB); $teamB = new Team(); $teamB->setPlayerA($playerC); $teamB->setPlayerB($playerD); $round = new Round(); $round->setDate(\DateTime::createFromFormat('Y-m-d', '1980-04-30')); $this->getEntityManager()->persist($teamA); $this->getEntityManager()->persist($teamB); $this->getEntityManager()->persist($round); $this->getEntityManager()->flush($teamA); $this->getEntityManager()->flush($teamB); $this->getEntityManager()->flush($round); return [$round, $teamA, $teamB]; }
/** * @Serializer\VirtualProperty() * @Serializer\SerializedName("id_round") */ public function getIdRound() { return $this->round->getId(); }
/** * @param array $dateStrings */ protected function createRounds(array $dateStrings, $flush = true) { foreach ($dateStrings as $dateString) { $round = new Round(); $round->setDate(\DateTime::createFromFormat('Y-m-d', $dateString)); $this->getEntityManager()->persist($round); if ($flush) { $this->getEntityManager()->flush($round); } } }