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()); }
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]); }