Skip to content

Add unit tests for the address-request guard and ajax response#110

Open
boo-code wants to merge 3 commits into
PrestaShop:mainfrom
boo-code:test/opc-handler-unit-coverage
Open

Add unit tests for the address-request guard and ajax response#110
boo-code wants to merge 3 commits into
PrestaShop:mainfrom
boo-code:test/opc-handler-unit-coverage

Conversation

@boo-code

@boo-code boo-code commented Jul 7, 2026

Copy link
Copy Markdown
Contributor
Questions Answers
Description? Adds unit coverage for two previously untested classes in the checkout AJAX layer. CheckoutAddressRequestGuard carried branching logic with no unit test; CheckoutAjaxResponse is the shared error/validation response shape. Covered: the guard's two early-return branches of isOwnedCheckoutAddress (non-positive address id, unresolved customer) and every branch of applyTemporaryInlineInvoiceAddress (billing mirrors delivery, persisted invoice address, missing billing country, and the inline-country mount); and both CheckoutAjaxResponse::error() / ::validation() shapes. Tests only — no production code changes. The gift-wrapping handler test this PR originally also carried has been dropped: #91 is the dedicated gift-wrapping test and covers that handler more fully.
Type? improvement
BC breaks? no
Deprecations? no
Fixed ticket?
Sponsor company
How to test? Run the unit suite; all green. The two new classes add 9 tests (CheckoutAddressRequestGuardTest, CheckoutAjaxResponseTest) within the established unit-test patterns (mocked collaborators, in-memory Configuration, anonymous Context/Cart fakes) and do not reach the database: isOwnedCheckoutAddress's Customer::customerHasAddress branch is intentionally left to the integration suite. php-cs-fixer clean; tests/ is outside the module PHPStan paths.

boo-code added 2 commits July 7, 2026 23:52
PrestaShop#91 (test/gift-wrapping-handler-coverage) is the dedicated gift-wrapping handler
test and covers the same handler more fully (cart-not-loaded, gift disabled,
message stored when enabled, and message cleared when disabled). Keeping a second
OpcGiftWrappingHandlerTest here only duplicated that coverage, so this PR now
focuses on the address-request guard and the ajax response helper.
@boo-code boo-code changed the title Add unit tests for the gift-wrapping handler, address-request guard, and ajax response Add unit tests for the address-request guard and ajax response Jul 7, 2026
@boo-code

boo-code commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Trimmed the scope: dropped the OpcGiftWrappingHandlerTest this PR originally carried, since #91 is the dedicated gift-wrapping test and covers that handler more fully (it also asserts the message-cleared-when-disabled branch). This PR now focuses on the address-request guard and the ajax response helper. Synced with main and updated the title/description to match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

2 participants