Beispiel #1
0
 public function testEditMatch()
 {
     $form = $this->createForm();
     $match = new DoubleMatch();
     $player1 = $this->getPlayer(1, 'Foo');
     $player2 = $this->getPlayer(2, 'Bar');
     $match->setTeamOne($player1, $player2);
     $player3 = $this->getPlayer(3, 'Foo');
     $player4 = $this->getPlayer(4, 'Bar');
     $match->setTeamTwo($player3, $player4);
     $game = new Game();
     $game->setGoalsTeamOne(10);
     $game->setGoalsTeamTwo(3);
     $match->addGame($game);
     $form->bind($match);
     $data = array('teamOneAttack' => 1, 'teamOneDefence' => 2, 'teamTwoAttack' => 3, 'teamTwoDefence' => 4, 'games' => array(array('id' => 1, 'goalsTeamOne' => 3, 'goalsTeamTwo' => 10)));
     $data['csrf'] = $form->get('csrf')->getCsrfValidator()->getHash(true);
     $form->setData($data);
     $valid = $form->isValid();
     $this->assertTrue($valid);
     /** @var $data \Application\Model\Entity\DoubleMatch */
     $data = $form->getData();
     $this->assertSame($match, $data);
     $games = $data->getGames();
     $this->assertSame($game, $games[0]);
 }
Beispiel #2
0
 public function testGetWinningTeamTwo()
 {
     $game = new Game();
     $game->setGoalsTeamOne(5);
     $game->setGoalsTeamTwo(10);
     $this->match->addGame($game);
     $player1 = new Player();
     $player2 = new Player();
     $this->match->setTeamOne($player1, $player2);
     $player3 = new Player();
     $player4 = new Player();
     $this->match->setTeamTwo($player3, $player4);
     $team = $this->match->getWinningTeam();
     $this->assertSame($player3, $team->getAttackingPlayer());
     $this->assertSame($player4, $team->getDefendingPlayer());
 }
Beispiel #3
0
 /**
  * @return int
  */
 protected function getPointsParticipant2()
 {
     if ($this->match instanceof SingleMatch) {
         return $this->match->getPlayer2()->getPoints();
     } else {
         if ($this->match instanceof DoubleMatch) {
             return $this->getPointsForTeam($this->match->getTeamTwo());
         }
     }
 }
Beispiel #4
0
 /**
  * Creates a new match
  *
  * @param AbstractTournament $tournament
  * @param Player             $player1
  * @param Player             $player2
  *
  * @return Match
  */
 public function getNew(AbstractTournament $tournament, $player1 = null, $player2 = null)
 {
     if ($tournament->getTeamType() == $tournament::TYPE_SINGLE) {
         $match = new SingleMatch();
         $match->setPlayer1($player1);
         $match->setPlayer2($player2);
     } else {
         $match = new DoubleMatch();
     }
     $gamesPerMatch = $tournament->getMinimumNumberOfGames();
     for ($i = 0; $i < $gamesPerMatch; $i++) {
         $match->addGame(new Game());
     }
     $match->setDate(new \DateTime());
     $match->setTournament($tournament);
     return $match;
 }