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,21 @@
<?php
namespace Tests\Unit\Controllers\Account\LifeEvent;
use Tests\FeatureTestCase;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class LifeEventCategoriesControllerTest extends FeatureTestCase
{
use DatabaseTransactions;
/** @test */
public function it_gets_the_list_of_life_event_categories()
{
$user = $this->signin();
$response = $this->get('settings/personalization/lifeeventcategories');
$response->assertStatus(200);
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Tests\Unit\Controllers\Auth;
use Tests\TestCase;
use App\Models\User\User;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Notification as NotificationFacade;
class PasswordResetTest extends TestCase
{
use DatabaseTransactions;
/** @test */
public function it_sends_password_reset_email()
{
NotificationFacade::fake();
$user = factory(User::class)->create();
$this->post('/password/email', ['email' => $user->email]);
NotificationFacade::assertSentTo($user, ResetPassword::class);
$notifications = NotificationFacade::sent($user, ResetPassword::class);
$message = $notifications[0]->toMail($user);
$this->assertStringContainsString('You are receiving this email because we received a password reset request for your account.', implode('', $message->introLines));
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Tests\Unit\Controllers\Contact;
use Tests\FeatureTestCase;
use App\Models\Contact\Contact;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ContactAuditLogControllerTest extends FeatureTestCase
{
use DatabaseTransactions;
/** @test */
public function it_gets_the_list_of_audit_logs_for_the_contact()
{
$user = $this->signin();
$contact = factory(Contact::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->get("/people/{$contact->hashID()}/auditlogs");
$response->assertStatus(200);
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Tests\Unit\Controllers\Contact;
use Tests\FeatureTestCase;
use App\Models\Contact\Contact;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class LifeEventsControllerTest extends FeatureTestCase
{
use DatabaseTransactions;
/** @test */
public function it_gets_the_list_of_life_events_for_the_contact()
{
$user = $this->signin();
$contact = factory(Contact::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->get("/people/{$contact->hashID()}/lifeevents");
$response->assertStatus(200);
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Tests\Unit\Controllers\Settings;
use Tests\FeatureTestCase;
use App\Models\Contact\Contact;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class AuditLogControllerTest extends FeatureTestCase
{
use DatabaseTransactions;
/** @test */
public function it_gets_the_list_of_audit_logs_for_the_account()
{
$user = $this->signin();
factory(Contact::class)->create([
'account_id' => $user->account_id,
]);
$response = $this->get('/settings/auditlogs');
$response->assertStatus(200);
}
}

View File

@@ -0,0 +1,202 @@
<?php
namespace Tests\Unit\Controllers\Settings;
use Tests\FeatureTestCase;
use App\Models\Contact\Gender;
use App\Models\Contact\Contact;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class GendersControllerTest extends FeatureTestCase
{
use DatabaseTransactions;
protected $jsonStructure = [
'id',
'name',
'type',
'isDefault',
'numberOfContacts',
];
protected $typesJsonStructure = [
'id',
'name',
];
/** @test */
public function it_gets_the_list_of_genders()
{
$user = $this->signin();
$response = $this->json('GET', '/settings/personalization/genders');
$response->assertStatus(200);
$response->assertJsonStructure([
'*' => $this->jsonStructure,
]);
$this->assertCount(
3,
$response->decodeResponseJson()
);
}
/** @test */
public function it_gets_the_list_of_genderTypes()
{
$user = $this->signin();
$response = $this->json('GET', '/settings/personalization/genderTypes');
$response->assertStatus(200);
$response->assertJsonStructure([
'*' => $this->typesJsonStructure,
]);
$this->assertCount(
5,
$response->decodeResponseJson()
);
}
/** @test */
public function it_stores_a_new_gender()
{
$user = $this->signin();
$response = $this->json('POST', '/settings/personalization/genders', [
'name' => 'gender',
'type' => 'O',
]);
$response->assertStatus(200);
$response->assertJsonStructure($this->jsonStructure);
$this->assertDataBaseHas('genders', [
'account_id' => $user->account_id,
'name' => 'gender',
'type' => 'O',
]);
}
/** @test */
public function it_stores_a_new_default_gender()
{
$user = $this->signin();
$this->assertNull($user->account->default_gender_id);
$response = $this->json('POST', '/settings/personalization/genders', [
'name' => 'new-default-gender',
'type' => 'O',
'isDefault' => 'true',
]);
$this->assertEquals($response->getData()->id, $user->account->default_gender_id);
}
/** @test */
public function it_updates_a_gender()
{
$user = $this->signin();
$gender = $user->account->genders()->first();
$response = $this->json('PUT', '/settings/personalization/genders/'.$gender->id, [
'name' => 'gender',
'type' => 'U',
]);
$response->assertStatus(200);
$response->assertJsonStructure($this->jsonStructure);
$this->assertDataBaseHas('genders', [
'account_id' => $user->account_id,
'id' => $gender->id,
'name' => 'gender',
]);
}
/** @test */
public function it_replaces_a_gender()
{
$user = $this->signin();
$genders = $user->account->genders()->get();
$gender1 = $genders[0]->id;
$gender2 = $genders[1]->id;
$contact = factory(Contact::class)->create([
'account_id' => $user->account_id,
'gender_id' => $gender1,
]);
$response = $this->json('DELETE', '/settings/personalization/genders/'.$gender1.'/replaceby/'.$gender2);
$this->expectObjectDeleted($response, $genders[0]->id);
$this->assertDataBaseMissing('genders', [
'account_id' => $user->account_id,
'id' => $genders[0]->id,
]);
$this->assertDataBaseHas('contacts', [
'account_id' => $user->account_id,
'id' => $contact->id,
'gender_id' => $gender2,
]);
}
/** @test */
public function it_replaces_a_gender_with_error()
{
$user = $this->signin();
$gender1 = factory(Gender::class)->create([
'account_id' => $user->account_id,
]);
$gender2 = factory(Gender::class)->create();
$response = $this->json('DELETE', '/settings/personalization/genders/'.$gender1->id.'/replaceby/'.$gender2->id);
$response->assertStatus(403);
$response->assertJson([
'message' => 'Please choose a gender from the list.',
]);
}
/** @test */
public function it_destroys_a_gender()
{
$user = $this->signin();
$gender = $user->account->genders()->first();
$response = $this->json('DELETE', '/settings/personalization/genders/'.$gender->id);
$this->expectObjectDeleted($response, $gender->id);
$this->assertDataBaseMissing('genders', [
'account_id' => $user->account_id,
'id' => $gender->id,
]);
}
/** @test */
public function it_updates_the_default_gender()
{
$user = $this->signin();
$gender = $user->account->genders()->first();
$this->assertNull($user->account->default_gender_id);
$response = $this->json('PUT', '/settings/personalization/genders/default/'.$gender->id);
$response->assertStatus(200);
$response->assertJsonStructure($this->jsonStructure);
$this->assertEquals($gender->id, $user->account->default_gender_id);
}
}