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,66 @@
<?php
namespace Tests\Unit\Services\Contact\Gift;
use Tests\TestCase;
use App\Models\Contact\Gift;
use App\Models\Account\Photo;
use Illuminate\Validation\ValidationException;
use App\Services\Contact\Gift\AssociatePhotoToGift;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class AssociateGiftToPhotoTest extends TestCase
{
use DatabaseTransactions;
/** @test */
public function it_associates_a_photo_to_a_gift()
{
$gift = factory(Gift::class)->create();
$photo = factory(Photo::class)->create([
'account_id' => $gift->account_id,
]);
$giftUpdated = app(AssociatePhotoToGift::class)->execute([
'account_id' => $gift->account_id,
'gift_id' => $gift->id,
'photo_id' => $photo->id,
]);
$this->assertInstanceOf(Gift::class, $giftUpdated);
$this->assertEquals($gift->id, $giftUpdated->id);
$this->assertDatabaseHas('gift_photo', [
'gift_id' => $gift->id,
'photo_id' => $photo->id,
]);
}
/** @test */
public function it_fails_if_wrong_parameters_are_given()
{
$this->expectException(ValidationException::class);
app(AssociatePhotoToGift::class)->execute([
'account_id' => -1,
'gift_id' => -1,
'photo_id' => -1,
]);
}
/** @test */
public function it_fails_if_photo_is_wrong_account()
{
$gift = factory(Gift::class)->create();
$photo = factory(Photo::class)->create();
$this->expectException(ModelNotFoundException::class);
app(AssociatePhotoToGift::class)->execute([
'account_id' => $gift->account_id,
'gift_id' => $gift->id,
'photo_id' => $photo->id,
]);
}
}

View File

@@ -0,0 +1,72 @@
<?php
namespace Tests\Unit\Services\Contact\Gift;
use Tests\TestCase;
use App\Models\Contact\Gift;
use App\Models\Account\Account;
use App\Models\Contact\Contact;
use App\Services\Contact\Gift\CreateGift;
use Illuminate\Validation\ValidationException;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class CreateGiftTest extends TestCase
{
use DatabaseTransactions;
/** @test */
public function it_creates_a_gift()
{
$contact = factory(Contact::class)->create();
$gift = app(CreateGift::class)->execute([
'account_id' => $contact->account_id,
'contact_id' => $contact->id,
'name' => 'Book',
'status' => 'idea',
]);
$this->assertDatabaseHas('gifts', [
'id' => $gift->id,
'account_id' => $contact->account_id,
'contact_id' => $contact->id,
'name' => 'Book',
'status' => 'idea',
]);
$this->assertInstanceOf(
Gift::class,
$gift
);
}
/** @test */
public function it_fails_if_wrong_parameters_are_given()
{
$this->expectException(ValidationException::class);
app(CreateGift::class)->execute([
'account_id' => -1,
'contact_id' => -1,
'name' => 'Book',
'status' => 'idea',
]);
}
/** @test */
public function it_fails_if_contact_is_wrong_account()
{
$account = factory(Account::class)->create();
$contact = factory(Contact::class)->create();
$this->expectException(ModelNotFoundException::class);
$gift = app(CreateGift::class)->execute([
'account_id' => $account->id,
'contact_id' => $contact->id,
'name' => 'Book',
'status' => 'idea',
]);
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace Tests\Unit\Services\Contact\Gift;
use Tests\TestCase;
use App\Models\Contact\Gift;
use App\Models\Account\Account;
use App\Services\Contact\Gift\DestroyGift;
use Illuminate\Validation\ValidationException;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class DestroyGiftTest extends TestCase
{
use DatabaseTransactions;
/** @test */
public function it_destroys_a_gift()
{
$gift = factory(Gift::class)->create();
$this->assertDatabaseHas('gifts', [
'account_id' => $gift->account_id,
'contact_id' => $gift->contact_id,
'id' => $gift->id,
]);
app(DestroyGift::class)->execute([
'account_id' => $gift->account_id,
'gift_id' => $gift->id,
]);
$this->assertDatabaseMissing('gifts', [
'id' => $gift->id,
]);
}
/** @test */
public function it_fails_if_wrong_parameters_are_given()
{
$this->expectException(ValidationException::class);
app(DestroyGift::class)->execute([
'account_id' => -1,
]);
}
/** @test */
public function it_fails_if_gift_is_wrong_account()
{
$account = factory(Account::class)->create();
$gift = factory(Gift::class)->create();
$this->expectException(ModelNotFoundException::class);
app(DestroyGift::class)->execute([
'account_id' => $account->id,
'gift_id' => $gift->id,
]);
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace Tests\Unit\Services\Contact\Gift;
use Tests\TestCase;
use App\Models\Contact\Gift;
use App\Models\Account\Account;
use App\Services\Contact\Gift\UpdateGift;
use Illuminate\Validation\ValidationException;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class UpdateGiftTest extends TestCase
{
use DatabaseTransactions;
/** @test */
public function it_updates_a_gift()
{
$gift = factory(Gift::class)->create();
$gift = app(UpdateGift::class)->execute([
'account_id' => $gift->account_id,
'gift_id' => $gift->id,
'contact_id' => $gift->contact_id,
'name' => 'Book',
'status' => 'offered',
]);
$this->assertDatabaseHas('gifts', [
'id' => $gift->id,
'name' => 'Book',
'status' => 'offered',
]);
$this->assertInstanceOf(
Gift::class,
$gift
);
}
/** @test */
public function it_fails_if_wrong_parameters_are_given()
{
$this->expectException(ValidationException::class);
app(UpdateGift::class)->execute([
'account_id' => -1,
'gift_id' => -1,
]);
}
/** @test */
public function it_throws_an_exception_if_gift_wrong_account()
{
$account = factory(Account::class)->create();
$gift = factory(Gift::class)->create();
$this->expectException(ModelNotFoundException::class);
app(UpdateGift::class)->execute([
'account_id' => $account->id,
'gift_id' => $gift->id,
'contact_id' => $gift->contact_id,
'name' => 'Book',
'status' => 'offered',
]);
}
}