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,73 @@
<?php
namespace Tests\Api\Contact;
use Tests\ApiTestCase;
use App\Models\Contact\Contact;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ApiMeControllerTest extends ApiTestCase
{
use DatabaseTransactions;
/** @test */
public function it_sets_me_contact()
{
$user = $this->signin();
$contact = factory(Contact::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('POST', '/api/me/contact', ['contact_id' => $contact->id]);
$response->assertStatus(200);
$this->assertDatabaseHas('users', [
'account_id' => $user->account_id,
'me_contact_id' => $contact->id,
]);
}
/** @test */
public function it_throws_an_error_if_wrong_account_on_sets_me_contact()
{
$this->signin();
$contact = factory(Contact::class)->create();
$response = $this->json('POST', '/api/me/contact', ['contact_id' => $contact->id]);
$this->expectNotFound($response);
}
/** @test */
public function it_throws_an_error_if_account_not_exists_on_sets_me_contact()
{
$this->signin();
$response = $this->json('POST', '/api/me/contact', ['contact_id' => 0]);
$this->expectDataError($response, [
'The selected contact id is invalid.',
]);
}
/** @test */
public function it_removes_me_contact()
{
$user = $this->signin();
$contact = factory(Contact::class)->create([
'account_id' => $user->account_id,
]);
$user->me_contact_id = $contact->id;
$user->save();
$response = $this->json('DELETE', '/api/me/contact');
$response->assertStatus(200);
$this->assertDatabaseHas('users', [
'account_id' => $user->account_id,
'me_contact_id' => null,
]);
}
}