Integrasi Login dan menu Dasar SIAKAD Operator dan Mahasiswa

This commit is contained in:
Ariyutta
2026-11-02 09:08:03 +07:00
parent b7a0c8705b
commit 43269095bf
68 changed files with 4287 additions and 216 deletions
+50
View File
@@ -0,0 +1,50 @@
<?php
namespace Tests\Feature\Mahasiswa;
use App\Enums\Role;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
/** KRS untuk akun demo (provider users): akses, halaman prototipe, dan aksi KRS asli tertutup. */
class KrsTest extends TestCase
{
use RefreshDatabase;
/** @return array<string, array{Role}> */
public static function otherRoles(): array
{
return [
'superuser' => [Role::Superuser],
'admin' => [Role::Admin],
'operator' => [Role::Operator],
'dosen' => [Role::Dosen],
];
}
public function test_guest_is_redirected_to_login(): void
{
$this->get(route('mahasiswa.krs'))->assertRedirect(route('login'));
$this->post(route('mahasiswa.krs.ambil'), ['jadwal' => 1])->assertRedirect(route('login'));
}
#[DataProvider('otherRoles')]
public function test_other_roles_are_forbidden(Role $role): void
{
$user = $this->userWithRole($role);
$this->actingAs($user)->get(route('mahasiswa.krs'))->assertForbidden();
$this->actingAs($user)->post(route('mahasiswa.krs.ambil'), ['jadwal' => 1])->assertForbidden();
$this->actingAs($user)->delete(route('mahasiswa.krs.hapus', 1))->assertForbidden();
}
public function test_demo_student_sees_the_prototype_and_cannot_use_real_actions(): void
{
$user = $this->userWithRole(Role::Mahasiswa);
$this->actingAs($user)->get(route('mahasiswa.krs'))->assertOk()->assertSee('Kartu Rencana Studi');
$this->actingAs($user)->post(route('mahasiswa.krs.ambil'), ['jadwal' => 1])->assertNotFound();
$this->actingAs($user)->delete(route('mahasiswa.krs.hapus', 1))->assertNotFound();
}
}