insert([ 'id' => 100, 'firstname' => 'Jane', 'lastname' => 'Doe', 'email' => 'jane@example.com', 'cellphone' => '555-1111', ]); DB::table('students')->insert([ 'id' => 200, 'parent_id' => 100, ]); $service = new AttendanceParentLookupService(); $result = $service->getPrimaryParentForStudent(200); $this->assertNotNull($result); $this->assertSame(100, $result['user_id']); $this->assertSame('jane@example.com', $result['email']); $this->assertSame('Jane Doe', $result['parent_name']); } public function test_get_secondary_parent_for_student_returns_secondary_user_when_present(): void { DB::table('users')->insert([ ['id' => 100, 'firstname' => 'Jane', 'lastname' => 'Doe', 'email' => 'jane@example.com', 'cellphone' => '555-1111'], ['id' => 101, 'firstname' => 'John', 'lastname' => 'Doe', 'email' => 'john@example.com', 'cellphone' => '555-2222'], ]); DB::table('students')->insert([ 'id' => 200, 'parent_id' => 100, 'school_year' => '2025-2026', ]); DB::table('parents')->insert([ 'firstparent_id' => 100, 'secondparent_id' => 101, 'school_year' => '2025-2026', 'updated_at' => now(), ]); $service = new AttendanceParentLookupService(); $result = $service->getSecondaryParentForStudent(200, '2025-2026'); $this->assertNotNull($result); $this->assertSame(101, $result['user_id']); $this->assertSame('john@example.com', $result['email']); } public function test_parents_info_returns_primary_and_secondary_data(): void { DB::table('users')->insert([ ['id' => 100, 'firstname' => 'Jane', 'lastname' => 'Doe', 'email' => 'jane@example.com', 'cellphone' => '555-1111'], ['id' => 101, 'firstname' => 'John', 'lastname' => 'Doe', 'email' => 'john@example.com', 'cellphone' => '555-2222'], ]); DB::table('students')->insert([ 'id' => 200, 'parent_id' => 100, 'school_year' => '2025-2026', ]); DB::table('parents')->insert([ 'firstparent_id' => 100, 'secondparent_id' => 101, 'school_year' => '2025-2026', 'updated_at' => now(), ]); $service = new AttendanceParentLookupService(); $result = $service->parentsInfo(200, '2025-2026'); $this->assertTrue($result['success']); $this->assertSame('jane@example.com', $result['data']['primary']['email']); $this->assertSame('john@example.com', $result['data']['secondary']['email']); } }