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,55 @@
<?php
namespace Tests\Unit\Services\Account\Gender;
use Tests\TestCase;
use App\Models\Contact\Gender;
use App\Models\Account\Account;
use App\Services\Account\Gender\CreateGender;
use Illuminate\Validation\ValidationException;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class CreateGenderTest extends TestCase
{
use DatabaseTransactions;
/** @test */
public function it_stores_a_gender()
{
$account = factory(Account::class)->create([]);
$request = [
'account_id' => $account->id,
'name' => 'man',
'type' => 'M',
];
$gender = app(CreateGender::class)->execute($request);
$this->assertDatabaseHas('genders', [
'id' => $gender->id,
'account_id' => $account->id,
'name' => 'man',
'type' => 'M',
]);
$this->assertInstanceOf(
Gender::class,
$gender
);
}
/** @test */
public function it_fails_if_wrong_parameters_are_given()
{
$account = factory(Account::class)->create([]);
$request = [
'name' => 'man',
'type' => 'X',
];
$this->expectException(ValidationException::class);
app(CreateGender::class)->execute($request);
}
}

View File

@@ -0,0 +1,60 @@
<?php
namespace Tests\Unit\Services\Account\Gender;
use Tests\TestCase;
use App\Models\Contact\Gender;
use App\Models\Account\Account;
use App\Services\Account\Gender\DestroyGender;
use Illuminate\Validation\ValidationException;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class DestroyGenderTest extends TestCase
{
use DatabaseTransactions;
/** @test */
public function it_destroys_a_gender()
{
$gender = factory(Gender::class)->create([]);
$request = [
'account_id' => $gender->account_id,
'gender_id' => $gender->id,
];
app(DestroyGender::class)->execute($request);
$this->assertDatabaseMissing('genders', [
'id' => $gender->id,
]);
}
/** @test */
public function it_throws_an_exception_if_account_is_not_linked_to_gender()
{
$account = factory(Account::class)->create([]);
$gender = factory(Gender::class)->create([]);
$request = [
'account_id' => $account->id,
'gender_id' => $gender->id,
];
$this->expectException(ModelNotFoundException::class);
app(DestroyGender::class)->execute($request);
}
/** @test */
public function it_throws_an_exception_if_ids_do_not_exist()
{
$request = [
'account_id' => 11111111,
'gender_id' => 11111111,
];
$this->expectException(ValidationException::class);
app(DestroyGender::class)->execute($request);
}
}

View File

@@ -0,0 +1,74 @@
<?php
namespace Tests\Unit\Services\Account\Gender;
use Tests\TestCase;
use App\Models\Contact\Gender;
use App\Models\Account\Account;
use App\Services\Account\Gender\UpdateGender;
use Illuminate\Validation\ValidationException;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class UpdateGenderTest extends TestCase
{
use DatabaseTransactions;
/** @test */
public function it_updates_a_gender()
{
$gender = factory(Gender::class)->create([]);
$request = [
'account_id' => $gender->account_id,
'gender_id' => $gender->id,
'name' => 'man',
'type' => 'M',
];
$gender = app(UpdateGender::class)->execute($request);
$this->assertDatabaseHas('genders', [
'id' => $gender->id,
'account_id' => $gender->account_id,
'name' => 'man',
'type' => 'M',
]);
$this->assertInstanceOf(
Gender::class,
$gender
);
}
/** @test */
public function it_fails_if_wrong_parameters_are_given()
{
$gender = factory(Gender::class)->create([]);
$request = [
'name' => 'man',
'type' => 'X',
];
$this->expectException(ValidationException::class);
app(UpdateGender::class)->execute($request);
}
/** @test */
public function it_throws_an_exception_if_place_is_not_linked_to_account()
{
$account = factory(Account::class)->create([]);
$gender = factory(Gender::class)->create([]);
$request = [
'account_id' => $account->id,
'gender_id' => $gender->id,
'name' => 'man',
'type' => 'M',
];
$this->expectException(ModelNotFoundException::class);
app(UpdateGender::class)->execute($request);
}
}