Files
CRM/tests/Unit/Services/Account/Gender/CreateGenderTest.php
Kroonk a213a1dba0
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
refactor: replace custom CRM with Monica fork
2026-05-22 16:19:55 +02:00

56 lines
1.3 KiB
PHP

<?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);
}
}