Skip to content

Cover the notify header shapes, AuthorizeAction paths and factory wiring - #67

Open
loevgaard wants to merge 3 commits into
2.xfrom
test/notify-authorize-integration
Open

Cover the notify header shapes, AuthorizeAction paths and factory wiring#67
loevgaard wants to merge 3 commits into
2.xfrom
test/notify-authorize-integration

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Fixes test gaps T2, T3 and T4 of #57 (T1 landed with #58, T5 with #65). Built on #60's branch merged with current 2.x — if #60 merges first this PR reduces to the test commit alone; merging this one first carries #60 along. Either order is clean.

What is covered now

  • T2 — NotifyAction::extractChecksum()'s real-world shapes. Lower-cased header names — what Symfony's HeaderBag actually produces, i.e. the production shape for Sylius/Symfony consumers — and list-valued headers. Both code paths existed but were untested (prime surviving-mutant territory).
  • T3 — AuthorizeAction beyond the happy path. The no-token path with a preset callback_url (must not need the token factory), the validateNotEmpty throw before any request goes out, the null-link-url LogicException, and branding_id propagation onto the wire — the factory tests guard the "optional option silently stops being read" failure mode for agreement; this pins it at the other end for branding_id.
  • T4 — factory-wired integration test. Convert → Authorize → Notify (signed callback, auto-capture fires) → GetStatus, through a gateway built by QuickpayGatewayFactory::create()": every action registered by the factory, apis injected by payum's own machinery, sub-requests routed through the real gateway, five wire calls asserted in order with the right credentials. The SDK client comes in via quickpay.client; the superglobal-reading default GetHttpRequestaction is replaced by passing the config key — the same override mechanismaddCoreGatewayFactoryConfig()` uses.

StatusAction, SyncAction and ConfirmPaymentAction already guarded the
missing-id case; AuthorizeAction, CaptureAction, RefundAction and
CancelAction did not — (int) $model['quickpayPaymentId'] on a missing key
is (int) null = 0, so the call went out as an operation on /payments/0
and came back as a NotFoundException after a network round trip, blaming
a payment id nobody ever set.

The new Details::paymentId() helper reads the id in one place: missing,
non-numeric or non-positive values throw a clear LogicException before
any HTTP happens (also catching a garbage id where the loose (int) cast
used to send 0), and a numeric string — the shape a serialization round
trip in the consumer's storage may produce — is accepted.
Three test gaps from the review:

- NotifyAction's checksum lookup handles lower-cased header names (the
  shape Symfony's HeaderBag actually produces in production) and
  list-valued headers — both paths existed but were untested.
- AuthorizeAction had one happy-path test. Now covered: the no-token
  path with a preset callback_url (no token factory needed), the
  missing-required-detail throw before any request, the null link url
  throw, and branding_id propagation onto the wire — the optional
  option whose silent loss the factory tests guard against for
  agreement, pinned at the other end.
- A factory-wired integration test: Convert → Authorize → Notify
  (signed, auto-captures) → GetStatus through a gateway built by
  QuickpayGatewayFactory::create(), with the SDK client injected via
  quickpay.client and the GetHttpRequest stub passed as the config key.
  The action tests construct their subjects by hand, so a
  mis-registered action or broken aware-interface hookup would slip
  past them; this is the test that catches it.
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.06%. Comparing base (cb6401c) to head (8b9890b).
⚠️ Report is 2 commits behind head on 2.x.

Files with missing lines Patch % Lines
src/Details.php 90.90% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x      #67      +/-   ##
============================================
+ Coverage     97.43%   98.06%   +0.63%     
- Complexity      126      132       +6     
============================================
  Files            14       15       +1     
  Lines           351      362      +11     
============================================
+ Hits            342      355      +13     
+ Misses            9        7       -2     

☔ 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.

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