Files
Mitgliederverwaltung/.plans/open/issue-206-missing-unit-tests.md
T
shahondin1624 b29a268b1d Restructure .plans/ into done/ and open/ subdirectories
- Move completed plan files to .plans/done/
- Move 18 open plan files to .plans/open/
- Update .gitignore to exclude .verified_plans temp file
- Verified all 18 open plans still describe unimplemented issues
2026-04-28 20:30:55 +02:00

1.9 KiB

Issue #206: Missing Unit Tests for Core Services

Problem

The codebase has PHP unit tests (tests/ directory) but the core services lack comprehensive test coverage. Key untested areas:

  • MemberService::create() - no tests for validation, duplicate detection
  • MemberService::update() - no tests for field filtering, partial updates
  • MemberService::softDelete() - no tests for data purge behavior
  • MemberService::findFiltered() - no tests for filter combinations
  • FeeCalculationService - mentioned in docs but tests may be incomplete
  • AuditService - no tests for field masking, diff computation

Impact

  • Risk of regressions when modifying services
  • Harder to refactor with confidence
  • Potential security issues (e.g., audit log masking) undetected

Solution

Add comprehensive unit tests using PHPUnit:

class MemberServiceTest extends\TestCase {
    
    /** @var MemberService */
    private $service;
    
    protected function setUp(): void {
        // Mock mappers and services
    }
    
    public function testCreateValidatesRequiredFields(): void {
        $this->expectException(ValidationException::class);
        $this->service->create([]);
    }
    
    public function testCreateDetectsDuplicates(): void {
        $this->expectException(DuplicateMemberException::class);
        $this->service->create([...]);
    }
    
    // ... more tests
}

Tasks

  • Set up PHPUnit with mocks for mappers and services
  • Test MemberService::create() - required fields, dates, duplicates
  • Test MemberService::update() - editable fields filter, partial updates
  • Test MemberService::softDelete() - data purge verification
  • Test MemberService::findFiltered() - all filter combinations
  • Test AuditService::maskIfEncrypted() - field masking
  • Test FeeCalculationService::calculateAnnualFee()
  • Achieve >70% code coverage

Labels

  • enhancement
  • testing
  • backend
  • priority:high