You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

121 lines
3.1 KiB

<?php
namespace Tests\Feature;
use App\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Tests\TestCase;
class ManageUserFamiliesTest extends TestCase
{
use DatabaseMigrations;
/** @test */
public function user_can_update_their_father()
{
$user = $this->loginAsUser();
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->submitForm('set_father_button', [
'set_father' => 'Nama Ayah',
]);
$this->seeInDatabase('users', [
'nickname' => 'Nama Ayah',
]);
$this->assertEquals('Nama Ayah', $user->fresh()->father->nickname);
}
/** @test */
public function user_can_update_their_mother()
{
$user = $this->loginAsUser();
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->submitForm('set_mother_button', [
'set_mother' => 'Nama Ibu',
]);
$this->seeInDatabase('users', [
'nickname' => 'Nama Ibu',
]);
$this->assertEquals('Nama Ibu', $user->fresh()->mother->nickname);
}
/** @test */
public function user_can_add_childrens()
{
$user = $this->loginAsUser(['gender_id' => 1]);
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->seeElement('input', ['name' => 'add_child_name']);
$this->seeElement('input', ['name' => 'add_child_gender_id']);
$this->submitForm('Tambah Anak', [
'add_child_name' => 'Nama Anak 1',
'add_child_gender_id' => 1,
]);
$this->seeInDatabase('users', [
'nickname' => 'Nama Anak 1',
'gender_id' => 1,
'father_id' => $user->id,
]);
}
/** @test */
public function user_can_set_wife()
{
$user = $this->loginAsUser(['gender_id' => 1]);
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->seeElement('input', ['name' => 'set_wife']);
$this->submitForm('set_wife_button', [
'set_wife' => 'Nama Istri',
]);
$this->seeInDatabase('users', [
'nickname' => 'Nama Istri',
'gender_id' => 2,
]);
$wife = User::orderBy('id', 'desc')->first();
$this->seeInDatabase('couples', [
'husband_id' => $user->id,
'wife_id' => $wife->id,
]);
}
/** @test */
public function user_can_set_husband()
{
$user = $this->loginAsUser(['gender_id' => 2]);
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->seeElement('input', ['name' => 'set_husband']);
$this->submitForm('set_husband_button', [
'set_husband' => 'Nama Suami',
]);
$this->seeInDatabase('users', [
'nickname' => 'Nama Suami',
'gender_id' => 1,
]);
$husband = User::orderBy('id', 'desc')->first();
$this->seeInDatabase('couples', [
'husband_id' => $husband->id,
'wife_id' => $user->id,
]);
}
}