public function testPostRequirements() { // create user info and convert it to json $user = factory(User::class)->create(); $userRequirement = factory(UserRequirement::class)->make(); $userRequirementData = json_encode(['data' => ['type' => 'user-requirements', 'attributes' => $userRequirement->toArray(), 'relationships' => ['user' => ['data' => ['type' => 'users', 'id' => $user->id]]]]]); // test getting all users $response = $this->callPost(self::API_URL, $userRequirementData); $this->assertEquals(Response::HTTP_CREATED, $response->getStatusCode()); $this->assertNotNull($userRequirementResponse = json_decode($response->getContent())->data); $this->assertNotEmpty($userRequirementResponse->id); // test to make sure the user was created try { $this->assertNotEmpty(UserRequirement::findOrFail($userRequirementResponse->id)); } catch (Exception $e) { $this->assertTrue(false, 'User account not found'); } }
public function destroy(UserRequirement $user_requirements) { $user_requirements->delete(); return response()->json('', Response::HTTP_NO_CONTENT); }