Exemple #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]);
 }
Exemple #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());
 }
Exemple #3
0
 /**
  * @param Game $game
  */
 public function addGame(Game $game)
 {
     $game->setMatch($this);
     $this->games[] = $game;
 }
Exemple #4
0
 /**
  * @param int $goalsTeamOne
  * @param int $goalsTeamTwo
  */
 protected function addGameToMatch($goalsTeamOne, $goalsTeamTwo)
 {
     $game = new Game();
     $game->setGoalsTeamOne($goalsTeamOne);
     $game->setGoalsTeamTwo($goalsTeamTwo);
     $this->match->addGame($game);
 }
Exemple #5
0
 /**
  * @param \Application\Model\PlayerRanking $player
  * @param int                              $teamIndex
  * @param int                              $opponentIndex
  * @param \Application\Model\Entity\Game   $game
  */
 protected function setRankingForPlayer($player, $teamIndex, $opponentIndex, $game)
 {
     $player->addGoals($game->getGoalsForTeam($teamIndex));
     $player->addGoalsAgainst($game->getGoalsForTeam($opponentIndex));
     $player->addPoints($this->getPointsForPlayer($game, $teamIndex));
 }
Exemple #6
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testGoalsForTeamWithInvalidIndex()
 {
     $this->game->setGoalsTeamTwo(3);
     $this->game->getGoalsForTeam(3);
 }