refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s

This commit is contained in:
Kroonk
2026-05-22 16:19:55 +02:00
parent 38cc4c09ca
commit a213a1dba0
2215 changed files with 242567 additions and 6015 deletions

View File

@@ -0,0 +1,183 @@
<?php
namespace Tests\Api\Account\Activity;
use Tests\ApiTestCase;
use App\Models\Account\ActivityTypeCategory;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ApiActivityTypeCategoryControllerTest extends ApiTestCase
{
use DatabaseTransactions;
protected $jsonStructureActivityTypeCategory = [
'id',
'object',
'name',
'account' => [
'id',
],
'created_at',
'updated_at',
];
/** @test */
public function it_gets_a_list_of_activity_type_categories()
{
$user = $this->signin();
factory(ActivityTypeCategory::class, 10)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/activitytypecategories');
$response->assertJsonStructure([
'data' => [
'*' => $this->jsonStructureActivityTypeCategory,
],
]);
}
/** @test */
public function it_applies_limit_parameter()
{
$user = $this->signin();
factory(ActivityTypeCategory::class, 10)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/activitytypecategories?limit=1');
$response->assertJsonFragment([
'total' => 10,
'current_page' => 1,
'per_page' => 1,
'last_page' => 10,
]);
$response = $this->json('GET', '/api/activitytypecategories?limit=2');
$response->assertJsonFragment([
'total' => 10,
'current_page' => 1,
'per_page' => 2,
'last_page' => 5,
]);
}
/** @test */
public function it_stores_a_activity_type_category()
{
$user = $this->signin();
$response = $this->json('POST', '/api/activitytypecategories', [
'name' => 'Movies',
]);
$response->assertStatus(200);
$this->assertDatabaseHas('activity_type_categories', [
'name' => 'Movies',
]);
$response->assertJsonStructure([
'data' => $this->jsonStructureActivityTypeCategory,
]);
}
/** @test */
public function it_updates_a_activity_type_category()
{
$user = $this->signin();
$activityTypeCategory = factory(ActivityTypeCategory::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('PUT', '/api/activitytypecategories/'.$activityTypeCategory->id, [
'name' => 'Movies',
]);
$response->assertStatus(200);
$this->assertDatabaseHas('activity_type_categories', [
'name' => 'Movies',
]);
$response->assertJsonStructure([
'data' => $this->jsonStructureActivityTypeCategory,
]);
}
/** @test */
public function it_doesnt_update_if_custom_field_not_found()
{
$user = $this->signin();
$response = $this->json('PUT', '/api/activitytypecategories/2349273984279348', [
'name' => 'Movies',
]);
$response->assertStatus(422);
$this->expectDataError($response, [
'The selected activity type category id is invalid.',
]);
}
/** @test */
public function it_deletes_a_activity_type_category()
{
$user = $this->signin();
$activityTypeCategory = factory(ActivityTypeCategory::class)->create([
'account_id' => $user->account_id,
'name' => 'France',
]);
$response = $this->delete('/api/activitytypecategories/'.$activityTypeCategory->id);
$response->assertStatus(200);
$this->assertDatabaseMissing('activity_type_categories', [
'id' => $activityTypeCategory->id,
]);
$response->assertJsonFragment([
'deleted' => true,
'id' => $activityTypeCategory->id,
]);
}
/** @test */
public function it_doesnt_delete_the_custom_field_if_not_found()
{
$user = $this->signin();
$response = $this->delete('/api/activitytypecategories/2349273984279348');
$response->assertStatus(422);
$this->expectDataError($response, [
'The selected activity type category id is invalid.',
]);
}
/** @test */
public function it_gets_a_single_activity_type_category()
{
$user = $this->signin();
$activityTypeCategory = factory(ActivityTypeCategory::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/activitytypecategories/'.$activityTypeCategory->id);
$response->assertJsonStructure([
'data' => $this->jsonStructureActivityTypeCategory,
]);
}
}

View File

@@ -0,0 +1,228 @@
<?php
namespace Tests\Api\Account\Activity;
use Tests\ApiTestCase;
use App\Models\Account\Activity;
use App\Models\Account\ActivityType;
use App\Models\Account\ActivityTypeCategory;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ApiActivityTypeControllerTest extends ApiTestCase
{
use DatabaseTransactions;
protected $jsonStructureActivityType = [
'id',
'object',
'name',
'location_type',
'activity_type_category' => [
'id',
'object',
'name',
'account' => [
'id',
],
'created_at',
'updated_at',
],
'account' => [
'id',
],
'created_at',
'updated_at',
];
/** @test */
public function it_gets_a_list_of_activity_types()
{
$user = $this->signin();
factory(ActivityType::class, 10)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/activitytypes');
$response->assertJsonStructure([
'data' => [
'*' => $this->jsonStructureActivityType,
],
]);
}
/** @test */
public function it_applies_limit_parameter()
{
$user = $this->signin();
$activityTypes = factory(ActivityType::class, 10)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/activitytypes?limit=1');
$response->assertJsonFragment([
'total' => 10,
'current_page' => 1,
'per_page' => 1,
'last_page' => 10,
]);
$response = $this->json('GET', '/api/activitytypes?limit=2');
$response->assertJsonFragment([
'total' => 10,
'current_page' => 1,
'per_page' => 2,
'last_page' => 5,
]);
}
/** @test */
public function it_stores_an_activity_type()
{
$user = $this->signin();
$activityTypeCategory = factory(ActivityTypeCategory::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('POST', '/api/activitytypes', [
'name' => 'Movies',
'activity_type_category_id' => $activityTypeCategory->id,
]);
$response->assertStatus(200);
$this->assertDatabaseHas('activity_types', [
'name' => 'Movies',
'activity_type_category_id' => $activityTypeCategory->id,
]);
$response->assertJsonStructure([
'data' => $this->jsonStructureActivityType,
]);
}
/** @test */
public function it_doesnt_store_an_activity_type_if_query_not_valid()
{
$user = $this->signin();
$response = $this->json('POST', '/api/activitytypes');
$this->expectDataError($response, [
'The activity type category id field is required.',
]);
}
/** @test */
public function it_updates_an_activity_type()
{
$user = $this->signin();
$activityTypeCategory = factory(ActivityTypeCategory::class)->create([
'account_id' => $user->account_id,
]);
$activityType = factory(ActivityType::class)->create([
'account_id' => $user->account_id,
'activity_type_category_id' => $activityTypeCategory->id,
]);
$response = $this->json('PUT', '/api/activitytypes/'.$activityType->id, [
'name' => 'Movies',
'activity_type_category_id' => $activityTypeCategory->id,
]);
$response->assertStatus(200);
$this->assertDatabaseHas('activity_types', [
'name' => 'Movies',
]);
$response->assertJsonStructure([
'data' => $this->jsonStructureActivityType,
]);
}
/** @test */
public function it_doesnt_update_if_activity_type_not_found()
{
$user = $this->signin();
$response = $this->json('PUT', '/api/activitytypes/2349273984279348', [
'name' => 'Movies',
]);
$this->expectDataError($response, [
'The activity type category id field is required.',
]);
}
/** @test */
public function it_deletes_an_activity_type()
{
$user = $this->signin();
$activityType = factory(ActivityType::class)->create([
'account_id' => $user->account_id,
]);
$activities = factory(Activity::class, 10)->create([
'account_id' => $user->account_id,
'activity_type_id' => $activityType->id,
]);
$response = $this->delete('/api/activitytypes/'.$activityType->id);
$response->assertStatus(200);
$this->assertDatabaseMissing('activity_types', [
'id' => $activityType->id,
]);
$this->assertDatabaseMissing('activities', [
'activity_type_id' => $activityType->id,
]);
$response->assertJsonFragment([
'deleted' => true,
'id' => $activityType->id,
]);
}
/** @test */
public function it_doesnt_delete_the_activity_type_if_not_found()
{
$user = $this->signin();
$response = $this->delete('/api/activitytypes/2349273984279348');
$this->expectDataError($response, [
'The selected activity type id is invalid.',
]);
}
/** @test */
public function it_gets_a_single_activity_type()
{
$user = $this->signin();
$activityTypeCategory = factory(ActivityTypeCategory::class)->create([
'account_id' => $user->account_id,
]);
$activityType = factory(ActivityType::class)->create([
'account_id' => $user->account_id,
'activity_type_category_id' => $activityTypeCategory->id,
]);
$response = $this->json('GET', '/api/activitytypes/'.$activityType->id);
$response->assertJsonStructure([
'data' => $this->jsonStructureActivityType,
]);
}
}

View File

@@ -0,0 +1,216 @@
<?php
namespace Tests\Api\Account;
use Tests\ApiTestCase;
use App\Models\Account\Account;
use App\Models\Account\Company;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ApiCompanyControllerTest extends ApiTestCase
{
use DatabaseTransactions;
protected $jsonCompany = [
'id',
'object',
'name',
'website',
'number_of_employees',
'account' => [
'id',
],
'created_at',
'updated_at',
];
/** @test */
public function it_gets_a_list_of_companies()
{
$user = $this->signin();
factory(Company::class, 3)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/companies');
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => ['*' => $this->jsonCompany],
]);
}
/** @test */
public function it_applies_the_limit_parameter_in_search()
{
$user = $this->signin();
factory(Company::class, 10)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/companies?limit=1');
$response->assertJsonFragment([
'total' => 10,
'current_page' => 1,
'per_page' => 1,
'last_page' => 10,
]);
$response = $this->json('GET', '/api/companies?limit=2');
$response->assertJsonFragment([
'total' => 10,
'current_page' => 1,
'per_page' => 2,
'last_page' => 5,
]);
}
/** @test */
public function it_gets_one_company()
{
$user = $this->signin();
$company = factory(Company::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('get', '/api/companies/'.$company->id);
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => $this->jsonCompany,
]);
$response->assertJsonFragment([
'object' => 'company',
'id' => $company->id,
]);
}
/** @test */
public function it_cant_get_a_call_with_unexistent_id()
{
$user = $this->signin();
$response = $this->json('get', '/api/companies/0');
$this->expectNotFound($response);
}
/** @test */
public function it_creates_a_company()
{
$user = $this->signin();
$response = $this->json('post', '/api/companies', [
'name' => 'Central Perk',
]);
$response->assertStatus(201);
$response->assertJsonStructure([
'data' => $this->jsonCompany,
]);
$companyId = $response->json('data.id');
$response->assertJsonFragment([
'object' => 'company',
'id' => $companyId,
]);
$this->assertDatabaseHas('companies', [
'account_id' => $user->account_id,
'id' => $companyId,
'name' => 'Central Perk',
'number_of_employees' => null,
]);
}
/** @test */
public function it_updates_a_company()
{
$user = $this->signin();
$company = factory(Company::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('put', '/api/companies/'.$company->id, [
'name' => 'Central Perk Central',
'number_of_employees' => 30,
]);
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => $this->jsonCompany,
]);
$companyId = $response->json('data.id');
$this->assertEquals($company->id, $companyId);
$response->assertJsonFragment([
'object' => 'company',
'id' => $companyId,
]);
$this->assertDatabaseHas('companies', [
'account_id' => $user->account_id,
'id' => $companyId,
'name' => 'Central Perk Central',
'number_of_employees' => 30,
]);
}
/** @test */
public function it_cant_update_a_company_if_account_is_not_linked_to_company()
{
$user = $this->signin();
$account = factory(Account::class)->create([]);
$company = factory(Company::class)->create([
'account_id' => $account->id,
]);
$response = $this->json('put', '/api/companies/'.$company->id, [
'name' => 'Central Perk',
]);
$this->expectNotFound($response);
}
/** @test */
public function it_deletes_a_company()
{
$user = $this->signin();
$company = factory(Company::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('delete', '/api/companies/'.$company->id);
$response->assertStatus(200);
$this->assertdatabasemissing('companies', [
'account_id' => $user->account_id,
'id' => $company->id,
]);
}
/** @test */
public function it_cant_delete_a_company_if_company_doesnt_exist()
{
$user = $this->signin();
$response = $this->json('delete', '/api/companies/0');
$this->expectDataError($response, [
'The selected company id is invalid.',
]);
}
}

View File

@@ -0,0 +1,236 @@
<?php
namespace Tests\Api\Account;
use Tests\ApiTestCase;
use App\Models\Contact\Gender;
use App\Models\Account\Account;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ApiGenderControllerTest extends ApiTestCase
{
use DatabaseTransactions;
protected $jsonGender = [
'id',
'object',
'name',
'type',
'account' => [
'id',
],
'created_at',
'updated_at',
];
/** @test */
public function it_gets_a_list_of_genders()
{
$user = $this->signin();
factory(Gender::class, 3)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/genders');
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => ['*' => $this->jsonGender],
]);
}
/** @test */
public function it_applies_the_limit_parameter_in_search()
{
$user = $this->signin();
factory(Gender::class, 10)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/genders?limit=1');
$response->assertJsonFragment([
'total' => 10,
'current_page' => 1,
'per_page' => 1,
'last_page' => 10,
]);
$response = $this->json('GET', '/api/genders?limit=2');
$response->assertJsonFragment([
'total' => 10,
'current_page' => 1,
'per_page' => 2,
'last_page' => 5,
]);
}
/** @test */
public function it_gets_one_gender()
{
$user = $this->signin();
$gender = factory(Gender::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('get', '/api/genders/'.$gender->id);
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => $this->jsonGender,
]);
$response->assertJsonFragment([
'object' => 'gender',
'id' => $gender->id,
]);
}
/** @test */
public function it_cant_get_a_gender_with_unexistent_id()
{
$user = $this->signin();
$response = $this->json('get', '/api/genders/0');
$this->expectNotFound($response);
}
/** @test */
public function it_creates_a_gender()
{
$user = $this->signin();
$response = $this->json('POST', '/api/genders', [
'name' => 'man',
'type' => 'M',
]);
$response->assertStatus(201);
$response->assertJsonStructure([
'data' => $this->jsonGender,
]);
$genderId = $response->json('data.id');
$response->assertJsonFragment([
'object' => 'gender',
'id' => $genderId,
]);
$this->assertDatabasehas('genders', [
'account_id' => $user->account_id,
'id' => $genderId,
'name' => 'man',
'type' => 'M',
]);
}
/** @test */
public function it_updates_a_gender()
{
$user = $this->signin();
$gender = factory(Gender::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('put', '/api/genders/'.$gender->id, [
'name' => 'man',
'type' => 'M',
]);
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => $this->jsonGender,
]);
$genderId = $response->json('data.id');
$this->assertEquals($gender->id, $genderId);
$response->assertJsonFragment([
'object' => 'gender',
'id' => $genderId,
]);
$this->assertDatabaseHas('genders', [
'account_id' => $user->account_id,
'id' => $genderId,
'name' => 'man',
'type' => 'M',
]);
}
/** @test */
public function it_cant_update_a_gender_if_account_is_not_linked_to_gender()
{
$user = $this->signin();
$account = factory(Account::class)->create([]);
$gender = factory(Gender::class)->create([
'account_id' => $account->id,
]);
$response = $this->json('put', '/api/genders/'.$gender->id, [
'name' => 'man',
'type' => 'M',
]);
$this->expectNotFound($response);
}
/** @test */
public function it_cant_update_a_gender_if_account_is_not_linked_to_gender2()
{
$user = $this->signin();
$account = factory(Account::class)->create([]);
$gender = factory(Gender::class)->create([
'account_id' => $account->id,
]);
$response = $this->json('put', '/api/genders/'.$gender->id, [
'account_id' => $account->id,
'name' => 'man',
'type' => 'M',
]);
$this->expectNotFound($response);
}
/** @test */
public function it_deletes_a_gender()
{
$user = $this->signin();
$gender = factory(Gender::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('delete', '/api/genders/'.$gender->id);
$response->assertStatus(200);
$this->assertDatabaseMissing('genders', [
'account_id' => $user->account_id,
'id' => $gender->id,
]);
}
/** @test */
public function it_cant_delete_a_gender_if_gender_doesnt_exist()
{
$user = $this->signin();
$response = $this->json('delete', '/api/genders/0');
$this->expectDataError($response, [
'The selected gender id is invalid.',
]);
}
}

View File

@@ -0,0 +1,210 @@
<?php
namespace Tests\Api\Account;
use Tests\ApiTestCase;
use App\Models\Account\Place;
use App\Models\Account\Account;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ApiPlaceControllerTest extends ApiTestCase
{
use DatabaseTransactions;
protected $jsonPlace = [
'id',
'object',
'street',
'city',
'province',
'postal_code',
'latitude',
'longitude',
'country',
'account' => [
'id',
],
'created_at',
'updated_at',
];
public function test_it_gets_a_list_of_places()
{
$user = $this->signin();
factory(Place::class, 3)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/places');
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => ['*' => $this->jsonPlace],
]);
}
public function test_it_applies_the_limit_parameter_in_search()
{
$user = $this->signin();
factory(Place::class, 10)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/places?limit=1');
$response->assertJsonFragment([
'total' => 10,
'current_page' => 1,
'per_page' => 1,
'last_page' => 10,
]);
$response = $this->json('GET', '/api/places?limit=2');
$response->assertJsonFragment([
'total' => 10,
'current_page' => 1,
'per_page' => 2,
'last_page' => 5,
]);
}
public function test_it_gets_one_place()
{
$user = $this->signin();
$place = factory(Place::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('get', '/api/places/'.$place->id);
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => $this->jsonPlace,
]);
$response->assertJsonFragment([
'object' => 'place',
'id' => $place->id,
]);
}
public function test_it_cant_get_a_call_with_unexistent_id()
{
$user = $this->signin();
$response = $this->json('get', '/api/places/0');
$this->expectNotFound($response);
}
public function test_it_create_a_place()
{
$user = $this->signin();
$response = $this->json('post', '/api/places', [
'city' => 'New York',
]);
$response->assertStatus(201);
$response->assertJsonStructure([
'data' => $this->jsonPlace,
]);
$placeId = $response->json('data.id');
$response->assertJsonFragment([
'object' => 'place',
'id' => $placeId,
]);
$this->assertDatabaseHas('places', [
'account_id' => $user->account_id,
'id' => $placeId,
'city' => 'New York',
'latitude' => null,
]);
}
public function test_it_updates_a_place()
{
$user = $this->signin();
$place = factory(Place::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('put', '/api/places/'.$place->id, [
'city' => 'New York',
]);
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => $this->jsonPlace,
]);
$placeId = $response->json('data.id');
$this->assertEquals($place->id, $placeId);
$response->assertJsonFragment([
'object' => 'place',
'id' => $placeId,
]);
$this->assertDatabaseHas('places', [
'account_id' => $user->account_id,
'id' => $placeId,
'city' => 'New York',
'latitude' => null,
]);
}
public function test_it_cant_update_a_place_if_account_is_not_linked_to_place()
{
$user = $this->signin();
$account = factory(Account::class)->create([]);
$place = factory(Place::class)->create([
'account_id' => $account->id,
]);
$response = $this->json('put', '/api/places/'.$place->id, [
'city' => 'New York',
]);
$this->expectNotFound($response);
}
public function test_it_deletes_a_place()
{
$user = $this->signin();
$place = factory(Place::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('delete', '/api/places/'.$place->id);
$response->assertStatus(200);
$this->assertdatabasemissing('places', [
'account_id' => $user->account_id,
'id' => $place->id,
]);
}
public function test_it_cant_delete_a_place_if_place_doesnt_exist()
{
$user = $this->signin();
$response = $this->json('delete', '/api/places/0');
$this->expectDataError($response, [
'The selected place id is invalid.',
]);
}
}

View File

@@ -0,0 +1,157 @@
<?php
namespace Tests\Api\Account;
use Tests\ApiTestCase;
use App\Models\Settings\Term;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ApiUserControllerTest extends ApiTestCase
{
use DatabaseTransactions;
protected $jsonStructureUser = [
'id',
'object',
'first_name',
'last_name',
'email',
'timezone',
'currency',
'locale',
'is_policy_compliant',
'account' => [
'id',
],
'created_at',
'updated_at',
];
/** @test */
public function it_gets_the_authenticated_user()
{
$user = $this->signIn();
$response = $this->get('/api/me');
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => $this->jsonStructureUser,
]);
$response->assertJsonFragment([
'first_name' => $user->first_name,
'object' => 'user',
]);
}
/** @test */
public function it_tells_if_the_user_has_signed_a_given_policy()
{
$user = $this->signIn();
$term = factory(Term::class)->create([]);
$user->terms()->syncWithoutDetaching([$term->id => ['account_id' => $user->account_id]]);
$response = $this->get('/api/me/compliance/'.$term->id);
$response->assertJsonFragment([
'signed' => true,
'ip_address' => null,
]);
$response->assertJsonStructure([
'data' => [
'signed',
'signed_date',
'ip_address',
'user',
'term',
],
]);
}
/** @test */
public function it_returns_method_not_found_if_no_policy_is_found()
{
$user = $this->signIn();
$response = $this->get('/api/me/compliance/32455212');
$response->assertStatus(404);
$response->assertJsonFragment([
'message' => 'The resource has not been found',
'error_code' => 31,
]);
}
/** @test */
public function it_gets_all_the_compliances_signed_by_user()
{
$user = $this->signIn();
$term = factory(Term::class)->create([]);
$user->terms()->syncWithoutDetaching([$term->id => ['account_id' => $user->account_id]]);
$term2 = factory(Term::class)->create([]);
$user->terms()->syncWithoutDetaching([$term2->id => ['account_id' => $user->account_id]]);
$response = $this->get('/api/me/compliance');
$response->assertStatus(200);
$response->assertJsonCount(2, 'data');
}
/** @test */
public function it_gets_no_compliances_signed_by_user()
{
$user = $this->signIn();
$response = $this->get('/api/me/compliance');
$response->assertStatus(404);
}
/** @test */
public function it_tries_to_sign_lapolicy()
{
$user = $this->signIn();
$response = $this->post('/api/me/compliance');
$this->expectDataError($response, [
'The ip address field is required.',
]);
}
/** @test */
public function it_signs_lapolicy()
{
$user = $this->signIn();
$term = factory(Term::class)->create([]);
$user->terms()->syncWithoutDetaching([$term->id => ['account_id' => $user->account_id]]);
$term2 = factory(Term::class)->create([]);
$user->terms()->syncWithoutDetaching([$term2->id => ['account_id' => $user->account_id]]);
$params = [
'ip_address' => '128.3.1.2',
];
$response = $this->json('POST', '/api/me/compliance', $params);
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => [
'signed',
'signed_date',
'ip_address',
'user',
'term',
],
]);
}
}