Cover the notify header shapes, AuthorizeAction paths and factory wiring - #67
Open
loevgaard wants to merge 3 commits into
Open
Cover the notify header shapes, AuthorizeAction paths and factory wiring#67loevgaard wants to merge 3 commits into
loevgaard wants to merge 3 commits into
Conversation
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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).AuthorizeActionbeyond the happy path. The no-token path with a presetcallback_url(must not need the token factory), thevalidateNotEmptythrow before any request goes out, the null-link-urlLogicException, andbranding_idpropagation onto the wire — the factory tests guard the "optional option silently stops being read" failure mode foragreement; this pins it at the other end forbranding_id.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 viaquickpay.client; the superglobal-reading defaultGetHttpRequestaction is replaced by passing the config key — the same override mechanismaddCoreGatewayFactoryConfig()` uses.