cuti-waf/tests/Feature/App/TesMembuatPengajuanCuti.php
2022-07-26 07:01:25 +07:00

63 lines
1.6 KiB
PHP

<?php
namespace Tests\Feature\App;
use App\Models\FormCuti;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class TesMembuatPengajuanCuti extends TestCase
{
use RefreshDatabase;
protected FormCuti $formCuti;
protected User $personalia;
protected User $supervisor;
protected User $staff;
protected function setUp(): void
{
parent::setUp();
$this->personalia = User::factory()->personalia()->create();
$this->supervisor = User::factory()->supervisor()->create();
$this->staff = User::factory()->staff()->create();
$this->formCuti = FormCuti::factory()->for($this->staff, 'staff')->for($this->personalia, 'creator')->create();
}
/** @test */
public function dapat_membuat_pengajuan_cuti()
{
$row = [
'tgl_mulai' => today(),
'tgl_selesai' => today()->addDays(4),
];
$this->formCuti->createRow($row);
$this->formCuti->save();
$this->assertSame(
[
'tgl_mulai' => $row['tgl_mulai']->toISOString(),
'tgl_selesai' => $row['tgl_selesai']->toISOString(),
'form_cuti_id' => $this->formCuti->id,
'supervisor' => [
'id' => null,
'terima' => false,
'keterangan' => null,
],
'personalia' => [
'id' => $this->personalia->id,
'terima' => false,
'keterangan' => null,
],
],
$this->formCuti->data[0]
);
}
}