2.5 KiB
2.5 KiB
Dev Log — 2026-03-30
Non-EB Claims API — Unit Tests
1. Added print_r Debug Output to All API Unit Tests
Added print_r($body) after every response body decode across all 4 test files so developers can see the actual JSON output directly in the terminal when running PHPUnit.
Files modified:
| File | Tests updated | Notes |
|---|---|---|
tests/unit/Api/ListClaimsTest.php |
5 tests | Pagination tests that didn't capture $resp were updated to capture it and print decoded body |
tests/unit/Api/ClaimHistoryTest.php |
6 tests | print_r($body) added after every $body = $this->body($resp) |
tests/unit/Api/UploadRequiredDocTest.php |
8 tests | print_r($body) added after every $body = $this->body($resp) |
tests/unit/Api/CreateClaimTest.php |
5 remaining tests | Already had it in 2 tests; added to the remaining 5 |
Pattern applied:
$body = $this->body($resp);
print_r($body); // ← added
$this->assertFalse($body['status']);
For pagination tests (testPerPageIsCappedAt100, testPerPageMinimumIsOne, testPageDefaultsToOne) that previously discarded the return value:
// before
$ctrl->listClaims();
// after
$resp = $ctrl->listClaims();
print_r(json_decode($resp->getBody(), true));
2. testReturns409OnDuplicateClaim — Explained How It Works
Investigated why changing nature_of_loss, loss_location, and client_id in $_POST still always produces 409. Key findings:
nature_of_loss/loss_location— not part ofcheckDuplicateNonEbClaim(), only used for validation (min length check)client_idin$_POST— never read from POST; controller derives it fromclientPolicyModelstub (client_id = 35)- Duplicate check only queries on:
client_id+loss_date+is_active(+policy_no) nonEbTicketModelstub (makeFluentStub(['id' => 55])) ignores all.where()chain calls and always returns['id' => 55]on->first()— meaning "duplicate found" unconditionally- The only way to change the 409 outcome is to make the
nonEbTicketModelstub returnnullon->first()
Files Modified
| File | Changes |
|---|---|
tests/unit/Api/ListClaimsTest.php |
print_r added to all 5 test methods |
tests/unit/Api/ClaimHistoryTest.php |
print_r added to all 6 test methods |
tests/unit/Api/UploadRequiredDocTest.php |
print_r added to all 8 test methods |
tests/unit/Api/CreateClaimTest.php |
print_r added to remaining 5 test methods |