Skip to content

README: add a 'Testing your callback endpoint' section - #7

Merged
loevgaard merged 1 commit into
1.xfrom
readme-callback-testing
Aug 6, 2026
Merged

README: add a 'Testing your callback endpoint' section#7
loevgaard merged 1 commit into
1.xfrom
readme-callback-testing

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Follow-up to the CallbackValidator/CallbackHandler design discussion: the classes deliberately have no interfaces and are final, which means consumers cannot mock them — and shouldn't. This section documents the intended pattern instead:

  • use a real CallbackHandler with a made-up test key (verification is deterministic, no I/O)
  • forge authentic signatures with $handler->validator()->sign($body) — this is the reason validator() is public, and it's the same pattern the SDK's own test suite uses
  • why mocking would be counterproductive: the checksum is over the raw byte-for-byte body, and the most common callback bug (a framework decoding/re-encoding or consuming the body before verification) is only caught by a real round-trip
  • includes the rejection-path example (tampered body → InvalidChecksumException)

Docs only — no code changes.

Documents the intended test pattern: a real CallbackHandler with a
made-up test key, forging authentic signatures via
$handler->validator()->sign() - which is why validator() is public.
Explains why mocking the (deliberately final) handler is a bad idea:
the checksum is over the raw byte-for-byte body, and only a real
round-trip catches frameworks re-encoding or consuming that body.
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.50%. Comparing base (425bd28) to head (cac9f18).

Additional details and impacted files
@@            Coverage Diff            @@
##                1.x       #7   +/-   ##
=========================================
  Coverage     98.50%   98.50%           
  Complexity      146      146           
=========================================
  Files            24       24           
  Lines           401      401           
=========================================
  Hits            395      395           
  Misses            6        6           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@loevgaard
loevgaard merged commit 419fb53 into 1.x Aug 6, 2026
35 checks passed
@loevgaard
loevgaard deleted the readme-callback-testing branch August 6, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant