Commit awal: prototipe UI SIAKAD Untan
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use App\Enums\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Aset Vite tidak dibutuhkan; tes tidak boleh bergantung pada `npm run build`.
|
||||
$this->withoutVite();
|
||||
}
|
||||
|
||||
/**
|
||||
* Buat akun untuk role tertentu beserta baris profilnya.
|
||||
*
|
||||
* @param array<string, mixed> $attributes kolom akun (name, username, is_active, ...)
|
||||
* @param array<string, mixed> $profile kolom profil (nim, nip, ...)
|
||||
*/
|
||||
protected function userWithRole(Role $role, array $attributes = [], array $profile = []): User
|
||||
{
|
||||
$user = User::factory()->state(['role' => $role])->create($attributes);
|
||||
|
||||
$role->profileModel()::factory()->create(['user_id' => $user->id, ...$profile]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user