Exemplo n.º 1
0
 /**
  * @Given /^there exist matches:$/
  *
  * @param TableNode $table
  *
  * @throws \Exception
  */
 public function thereExistMatches(TableNode $table)
 {
     $container = $this->getClient()->getContainer();
     $objectManager = $container->get('doctrine.orm.entity_manager');
     foreach ($table->getHash() as $row) {
         switch ($row['createdAt']) {
             case 'current':
                 $matchDate = new \DateTime();
                 break;
             default:
                 $matchDate = \DateTime::createFromFormat(Constants::DATE_FORMAT, $row['createdAt']);
                 if ($matchDate === false) {
                     throw new \Exception('Cannot create date');
                 }
                 break;
         }
         $match = new Match();
         $match->setPublicId($row['publicId'])->setToken($row['token'])->setCreatedAt($matchDate)->setStatus($row['status']);
         $objectManager->persist($match);
     }
     $objectManager->flush();
 }
Exemplo n.º 2
0
 public function buildMatch()
 {
     $match = new Match();
     $match->setPublicId($this->publicIdGenerator->generateToken())->setToken($this->matchTokenGenerator->generateToken())->setCreatedAt(new \DateTime())->setStatus(Match::STATUS_WAITING_FOR_PLAYERS);
     return $match;
 }