コード例 #1
0
 public function testPatchTournamentLocations()
 {
     // create user info and convert it to json
     $location = factory(Location::class)->create();
     $tournament = factory(Tournament::class)->create(['location_id' => $location->id]);
     $tournamentLocationObject = factory(TournamentLocation::class)->create(['tournament_id' => $tournament->id]);
     $tournamentLocationObject->street = '9999 street name';
     $tournamentLocationData = json_encode(['data' => ['type' => 'tournament-locations', 'attributes' => $tournamentLocationObject->toArray(), 'relationships' => ['tournament' => ['data' => ['type' => 'tournaments', 'id' => $tournament->id]]]]]);
     $response = $this->callPatch(self::API_URL . $tournamentLocationObject->id, $tournamentLocationData);
     $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
     $this->assertNotNull($tournamentLocation = json_decode($response->getContent())->data);
     $this->assertNotEmpty($tournamentLocation->id);
     // test to make sure the user was created
     $updatedTournamentLocation = TournamentLocation::findOrFail($tournamentLocation->id);
     $this->assertEquals('9999 street name', $updatedTournamentLocation->street);
     $this->assertEquals($updatedTournamentLocation->tournament->toArray(), $tournament->toArray());
 }