b29a268b1d
- 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
1.9 KiB
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 detectionMemberService::update()- no tests for field filtering, partial updatesMemberService::softDelete()- no tests for data purge behaviorMemberService::findFiltered()- no tests for filter combinationsFeeCalculationService- mentioned in docs but tests may be incompleteAuditService- 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