コード例 #1
0
 /**
  * @param $matchId
  * @return mixed
  */
 private static function simulate($matchId)
 {
     $match = \App\Lib\DsManager\Models\Match::fromArray(MatchOrm::complete()->where(['id' => $matchId])->first()->toArray());
     $matchResult = $match->simulate()->toArray();
     $result = MatchResult::where(['id' => $matchId])->update(MatchResult::resolveAttributes($matchResult, $matchId));
     return $result;
 }
コード例 #2
0
 /**
  * @group Match
  * @group createnewmatch
  */
 public function testCreateNewMatch()
 {
     $teams = \App\Lib\DsManager\Models\Orm\Team::with('roster', 'coach')->get();
     $this->assertNotNull($teams);
     $teams = $teams->toArray();
     $homeIndex = array_rand($teams);
     $teamHome = $teams[$homeIndex];
     unset($teams[$homeIndex]);
     $teamAway = $teams[array_rand($teams)];
     $this->assertNotNull($teamHome);
     $this->assertNotNull($teamAway);
     $matchO = \App\Lib\DsManager\Models\Orm\Match::create(['home_team_id' => $teamHome['id'], 'away_team_id' => $teamAway['id']]);
     $this->assertNotNull($matchO);
     $matchNew = \App\Lib\DsManager\Models\Orm\Match::complete()->where('id', $matchO->id)->first();
     $this->assertNotNull($matchNew);
     $match = \App\Lib\DsManager\Models\Match::fromArray($matchNew->toArray());
     $this->assertNotNull($match);
 }