'Company Admin', 'email' => 'admin@company.com', 'password' => bcrypt('password'), 'type' => 'company', ]); $this->branch = Branch::create([ 'name' => 'Main Branch', 'created_by' => $companyUser->id, ]); $this->user = User::create([ 'name' => 'Test Employee', 'email' => 'testemployee@example.com', 'password' => bcrypt('password'), 'type' => 'employee', 'created_by' => $companyUser->id, 'branch_id' => $this->branch->id, ]); $this->employee = Employee::create([ 'user_id' => $this->user->id, 'employee_id' => 'EMPTEST002', 'branch_id' => $this->branch->id, 'rest_days' => ['sunday'], 'date_of_joining' => '2026-08-01', 'created_by' => $companyUser->id, ]); } public function test_clock_in_and_clock_out_persists_mobile_source() { $service = app(AttendanceService::class); // Clock In $resultIn = $service->processClock($this->user, $this->employee, [ 'action' => 'clock_in', 'latitude' => 14.5995, 'longitude' => 120.9842, ]); $this->assertTrue($resultIn['success']); $record = AttendanceRecord::where('employee_id', $this->user->id)->first(); $this->assertNotNull($record); $this->assertEquals('mobile', $record->clock_in_source); // Clock Out $resultOut = $service->processClock($this->user, $this->employee, [ 'action' => 'clock_out', 'latitude' => 14.5995, 'longitude' => 120.9842, ]); $this->assertTrue($resultOut['success']); $record->refresh(); $this->assertEquals('mobile', $record->clock_out_source); } }