コード例 #1
0
 public function testPostWaivers()
 {
     // create a user with waivers
     $user = factory(User::class)->create();
     $userWaiver = factory(UserWaiver::class)->make();
     $userWaiverData = json_encode(['data' => ['type' => 'user-waivers', 'attributes' => $userWaiver->toArray(), 'relationships' => ['user' => ['data' => ['type' => 'users', 'id' => $user->id]], 'by' => []]]]);
     // test getting all users
     $response = $this->callPost(self::API_URL, $userWaiverData);
     $this->assertEquals(Response::HTTP_CREATED, $response->getStatusCode());
     $this->assertNotNull($userWaierResponse = json_decode($response->getContent())->data);
     $this->assertNotEmpty($userWaierResponse->id);
     // test to make sure the user was created
     try {
         $this->assertNotEmpty(UserWaiver::findOrFail($userWaierResponse->id));
     } catch (Exception $e) {
         $this->assertTrue(false, 'User account not found');
     }
 }
コード例 #2
0
 public function destroy(UserWaiver $user_waivers)
 {
     $user_waivers->delete();
     return response()->json('', Response::HTTP_NO_CONTENT);
 }