refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
This commit is contained in:
68
tests/Unit/Models/GenderTest.php
Normal file
68
tests/Unit/Models/GenderTest.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Models;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Models\Contact\Gender;
|
||||
use App\Models\Account\Account;
|
||||
use App\Models\Contact\Contact;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class GenderTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/** @test */
|
||||
public function it_belongs_to_an_account()
|
||||
{
|
||||
$account = factory(Account::class)->create([]);
|
||||
$gender = factory(Gender::class)->create([
|
||||
'account_id' => $account->id,
|
||||
]);
|
||||
|
||||
$this->assertTrue($gender->account()->exists());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_belongs_to_many_contacts()
|
||||
{
|
||||
$account = factory(Account::class)->create([]);
|
||||
$gender = factory(Gender::class)->create([
|
||||
'account_id' => $account->id,
|
||||
]);
|
||||
$contact = factory(Contact::class)->create(['account_id' => $account->id, 'gender_id' => $gender->id]);
|
||||
$contact = factory(Contact::class)->create(['account_id' => $account->id, 'gender_id' => $gender->id]);
|
||||
|
||||
$this->assertTrue($gender->contacts()->exists());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_gets_the_gender_name()
|
||||
{
|
||||
$gender = new Gender;
|
||||
$gender->name = 'Woman';
|
||||
|
||||
$this->assertEquals(
|
||||
'Woman',
|
||||
$gender->name
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_gets_the_default_gender()
|
||||
{
|
||||
$account = factory(Account::class)->create();
|
||||
$gender = Gender::create([
|
||||
'account_id' => $account->id,
|
||||
'name' => 'Woman',
|
||||
]);
|
||||
|
||||
$this->assertFalse($gender->isDefault());
|
||||
|
||||
$account->default_gender_id = $gender->id;
|
||||
$account->save();
|
||||
$gender->refresh();
|
||||
|
||||
$this->assertTrue($gender->isDefault());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user