create(); $this->program = Program::factory()->published()->create(['created_by' => $admin->id]); $this->participant = Participant::create([ 'name' => 'Peserta Sijil', 'no_kp' => '900101011234', 'email' => 'sijil@test.com', 'participant_type' => 'staff', ]); $this->certificate = Certificate::create([ 'program_id' => $this->program->id, 'participant_id' => $this->participant->id, 'token' => 'cert-token-test-48-chars-xxxxxxxxxxxxxxxxxxxxxxxxx', 'status' => 'generated', 'generated_at' => now(), 'certificate_no' => 'ECT/2025/0001', ]); } public function test_certificate_show_page_loads_for_generated_certificate(): void { $this->get("/certificate/{$this->certificate->token}") ->assertOk() ->assertSee('Sijil Sedia Dimuat Turun'); } public function test_pending_certificate_shows_not_ready_message(): void { $this->certificate->update(['status' => 'pending']); $this->get("/certificate/{$this->certificate->token}") ->assertOk() ->assertSee('Sijil Belum Sedia'); } public function test_invalid_certificate_token_returns_404(): void { $this->get('/certificate/invalid-token-xxxx')->assertNotFound(); } public function test_semak_kehadiran_shows_result_for_valid_no_kp(): void { $qrCode = ProgramQrCode::create([ 'program_id' => $this->program->id, 'token' => 'semak-token-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'qr_image_path' => 'qrcodes/test.png', 'is_active' => true, ]); ProgramParticipant::create([ 'program_id' => $this->program->id, 'participant_id' => $this->participant->id, 'registration_source' => 'pre_registered', 'is_pre_registered' => true, 'pre_registered_session' => 'pagi', 'status' => 'checked_in', ]); Attendance::create([ 'program_id' => $this->program->id, 'participant_id' => $this->participant->id, 'attendance_session' => 'pagi', 'attendance_source' => 'pre_registered_staff', 'checked_in_at' => now(), ]); $this->post("/p/{$qrCode->token}/semak", [ 'no_kp' => '900101011234', ])->assertViewIs('public.semak.result'); } }