Exemplo n.º 1
0
 /**
  * Initially didGoal is a null variable, and whether the team scored or not we make true or false
  * this way the class worked if that variable has a value, otherwise it failed
  */
 function testActionReturnBoolean()
 {
     $attackTeam = Mockery::mock("Offside\\Repo\\TeamRepository");
     $defenseTeam = Mockery::mock("Offside\\Repo\\TeamRepository");
     $attackTeam->shouldReceive("getOverallAttack")->andReturn(80);
     $attackTeam->shouldReceive("getOverallStamina")->andReturn(50);
     $defenseTeam->shouldReceive("getOverallDefense")->andReturn(70);
     $defenseTeam->shouldReceive("getOverallStamina")->andReturn(30);
     $attackTeam->shouldReceive("getOverallSuccessConversion")->andReturn(80);
     $attack = new Action($attackTeam, $defenseTeam);
     $attack->calculateResulsts();
     $this->assertEquals(true, !is_null($attack->didGoalSucceed()));
 }
Exemplo n.º 2
0
 /**
  * Calculate for both teams number of actions
  * and make them happen using Action class
  *
  * @internal param TeamRepository $firstTeam
  * @internal param TeamRepository $secondTeam
  * @return \Offside\Match\MatchResults
  */
 public function generateActions()
 {
     $firstTeam = $this->firstTeam;
     $secondTeam = $this->secondTeam;
     //initialize a MatchAction object with each team and attach to this object
     $firstTeamAction = $firstTeam->getNumberOfActions();
     for ($counter = 0; $counter < $firstTeamAction; $counter++) {
         $cur_action = new Action($firstTeam, $secondTeam);
         $cur_action->attach($this);
         $cur_action->calculateResulsts();
         $cur_action->detach($this);
     }
     $secondTeamAction = $firstTeam->getNumberOfActions();
     for ($counter = 0; $counter < $secondTeamAction; $counter++) {
         $cur_action = new Action($secondTeam, $firstTeam);
         $cur_action->attach($this);
         $cur_action->calculateResulsts();
         $cur_action->detach($this);
     }
     return new MatchResults($firstTeam, $secondTeam);
 }