Integrasi Login dan menu Dasar SIAKAD Operator dan Mahasiswa
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Mahasiswa;
|
||||
|
||||
use App\Enums\Role;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tests\TestCase;
|
||||
|
||||
/** Transkrip untuk akun demo (provider users): akses dan halaman dasar. Data asli diuji di LegacyTranskripTest. */
|
||||
class TranskripTest 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.transkrip'))->assertRedirect(route('login'));
|
||||
}
|
||||
|
||||
#[DataProvider('otherRoles')]
|
||||
public function test_other_roles_are_forbidden(Role $role): void
|
||||
{
|
||||
$this->actingAs($this->userWithRole($role))->get(route('mahasiswa.transkrip'))->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_mahasiswa_sees_the_page(): void
|
||||
{
|
||||
$this->actingAs($this->userWithRole(Role::Mahasiswa))
|
||||
->get(route('mahasiswa.transkrip'))
|
||||
->assertOk()
|
||||
->assertSee('Transkrip nilai')
|
||||
->assertSee('Unduh PDF');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user