示例#1
0
 /**
  * @param $request
  * @param $response
  * @param $attributesToCheck
  *
  * @dataProvider matchUpdatesWithRequests
  */
 public function testUpdateMatchScore($request, $response, $attributesToCheck)
 {
     $member = Factory::create('App\\Models\\Member');
     Auth::login($member);
     /**
      * @var $tournament Tournament
      * @var $league League
      * @var $homeTeam Team
      * @var $awayTeam Team
      * @var $homeTournamentTeam TournamentTeam
      * @var $awayTournamentTeam TournamentTeam
      * @var $match Match
      */
     $tournament = Factory::create('App\\Models\\Tournament');
     $league = Factory::create('App\\Models\\League');
     $homeTeam = Factory::create('App\\Models\\Team', ['leagueId' => $league->id]);
     $awayTeam = Factory::create('App\\Models\\Team', ['leagueId' => $league->id]);
     $homeTournamentTeam = Factory::create('App\\Models\\TournamentTeam', ['teamId' => $homeTeam->id, 'tournamentId' => $tournament->id]);
     $awayTournamentTeam = Factory::create('App\\Models\\TournamentTeam', ['teamId' => $awayTeam->id, 'tournamentId' => $tournament->id]);
     $match = Factory::create('App\\Models\\Match', ['tournamentId' => $tournament->id, 'homeTournamentTeamId' => $homeTournamentTeam->id, 'awayTournamentTeamId' => $awayTournamentTeam->id]);
     $this->put('/api/v1/matches/' . $match->id, ['match' => $request], ['HTTP_X-Requested-With' => 'XMLHttpRequest', 'HTTP_CONTENT_TYPE' => 'application/json', 'HTTP_ACCEPT' => 'application/json']);
     $this->assertResponseStatus($response['status']);
     if (!empty($result)) {
         $updatedRow = Match::find($match->id);
         foreach ($result as $property => $value) {
             $this->assertEquals($value, $updatedRow->getAttribute($property));
         }
     }
 }
 /**
  * Tests if the remove match on the repo
  * works correclty.
  */
 public function testRemoveMatchRemovalSuccess()
 {
     $match = Factory::create('App\\Models\\Match');
     $result = $this->repository->removeMatch(Administrator::find($match->created_by), $match->id);
     $this->assertTrue($result);
     $this->assertNull(Match::find($match->id));
 }