*/ 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(); } }