Exemplo n.º 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]);
 }
Exemplo n.º 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());
 }
Exemplo n.º 3
0
Arquivo: Match.php Projeto: 0ida/fussi
 /**
  * @param Game $game
  */
 public function addGame(Game $game)
 {
     $game->setMatch($this);
     $this->games[] = $game;
 }
Exemplo n.º 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);
 }
Exemplo n.º 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));
 }
Exemplo n.º 6
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testGoalsForTeamWithInvalidIndex()
 {
     $this->game->setGoalsTeamTwo(3);
     $this->game->getGoalsForTeam(3);
 }