Files
siakad/tests/Feature/Mahasiswa/KhsTest.php
T

47 lines
1.3 KiB
PHP

<?php
namespace Tests\Feature\Mahasiswa;
use App\Enums\Role;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
/** KHS untuk akun demo (provider users): akses dan halaman dasar. Data asli diuji di LegacyKhsTest. */
class KhsTest 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.khs'))->assertRedirect(route('login'));
}
#[DataProvider('otherRoles')]
public function test_other_roles_are_forbidden(Role $role): void
{
$this->actingAs($this->userWithRole($role))->get(route('mahasiswa.khs'))->assertForbidden();
}
public function test_mahasiswa_sees_the_page(): void
{
$this->actingAs($this->userWithRole(Role::Mahasiswa))
->get(route('mahasiswa.khs'))
->assertOk()
->assertSee('<h1', false)
->assertSee('Kartu Hasil Studi')
->assertSee('Semester 8');
}
}