예제 #1
0
 function run()
 {
     $teamNumber = 16;
     $rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
     for ($i = 1; $i <= $teamNumber; $i++) {
         $team = $rndFiller->getTeam($rndFiller->getLocale());
         $teamArray = $team->toArray();
         $teamO = \App\Lib\DsManager\Models\Orm\Team::create($teamArray);
         foreach ($teamArray['roster'] as $player) {
             $player['team_id'] = $teamO->id;
             \App\Lib\DsManager\Models\Orm\Player::create($player);
         }
         $teamArray['coach']['team_id'] = $teamO->id;
         \App\Lib\DsManager\Models\Orm\Coach::create($teamArray['coach']);
     }
 }
예제 #2
0
 /**
  * @group OrmModels
  * @group TeamOrm
  */
 public function testTeamOrm()
 {
     $rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
     $team = $rndFiller->getTeam($rndFiller->getLocale());
     $teamArray = $team->toArray();
     $this->assertNotEmpty($team);
     $teamO = \App\Lib\DsManager\Models\Orm\Team::create($teamArray);
     $this->assertNotEmpty($teamArray);
     $this->assertNotEmpty($teamArray['roster']);
     foreach ($teamArray['roster'] as $player) {
         $player['team_id'] = $teamO->id;
         $playerO = \App\Lib\DsManager\Models\Orm\Player::create($player);
         $this->assertNotEmpty($playerO);
     }
     $teamArray['coach']['team_id'] = $teamO->id;
     $coachO = \App\Lib\DsManager\Models\Orm\Coach::create($teamArray['coach']);
     $this->assertNotEmpty($coachO);
     $this->assertNotEmpty(\App\Lib\DsManager\Models\Orm\Team::with('roster')->with('coach')->where(['id' => $teamO->id])->get()->toArray());
 }