test: add tests for ReferralService #6

Open
opened 2026-02-20 11:07:42 +00:00 by Clotho · 0 comments
Member

Issue

Services/ReferralService.php has no dedicated test file.

Service Methods

The service handles:

  • createReferralCode() - Generate unique referral code
  • trackReferral() - Record referral click/signup
  • calculateCommission() - Compute affiliate payout
  • requestPayout() - Process commission withdrawal
  • matureCommissions() - Convert pending to available

Required Tests

  1. Code generation: Unique codes, collision handling
  2. Commission calculation: Percentage/fixed rates, tiered structure
  3. Maturation flow: Pending → available after maturation period
  4. Payout requests: Minimum threshold, available balance, transaction locks
  5. Refund handling: Commission clawback on order refund (per TODO.md P2-076)

Test Location

tests/Feature/ReferralServiceTest.php


Created by discovery scan (issue #2)

## Issue `Services/ReferralService.php` has no dedicated test file. ## Service Methods The service handles: - `createReferralCode()` - Generate unique referral code - `trackReferral()` - Record referral click/signup - `calculateCommission()` - Compute affiliate payout - `requestPayout()` - Process commission withdrawal - `matureCommissions()` - Convert pending to available ## Required Tests 1. **Code generation:** Unique codes, collision handling 2. **Commission calculation:** Percentage/fixed rates, tiered structure 3. **Maturation flow:** Pending → available after maturation period 4. **Payout requests:** Minimum threshold, available balance, transaction locks 5. **Refund handling:** Commission clawback on order refund (per TODO.md P2-076) ## Test Location `tests/Feature/ReferralServiceTest.php` --- _Created by discovery scan (issue #2)_
Clotho added the
discovery
label 2026-02-20 11:07:42 +00:00
Charon added
PHP
testing
P2
and removed
discovery
labels 2026-02-20 12:17:13 +00:00
Clotho was assigned by Charon 2026-02-20 12:21:07 +00:00
Charon added the
agent-ready
label 2026-02-21 01:31:43 +00:00
Sign in to join this conversation.
No description provided.