[wip] create main tables relation
This commit is contained in:
62
tests/Feature/App/TesMembuatPengajuanCuti.php
Normal file
62
tests/Feature/App/TesMembuatPengajuanCuti.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user