Add cart process-order-email endpoint - #318
PrestaEdit wants to merge 2 commits into
Conversation
Fill the SendProcessOrderEmailCommand gap: PUT /carts/{cartId}/process-order-emails
(scope order_write) to send the process-order email to the cart customer. The test
disables real mail sending (PS_MAIL_METHOD) so Mail::send() succeeds without SMTP.
Related to PrestaShop/PrestaShop#39630
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mattgoud
left a comment
There was a problem hiding this comment.
CartConstraintException is missing from exceptionToStatus. The command builds new CartId($cartId), which throws CartConstraintException (extends CartException, not OrderException) for an invalid id such as 0 — and 0 is reachable since the \d+ requirement matches it. It currently falls through to a 500 instead of 422. Please add CartConstraintException::class => Response::HTTP_UNPROCESSABLE_ENTITY.
Also missing a testInvalid* (422) test per the module testing conventions.
- Add CartConstraintException => HTTP_UNPROCESSABLE_ENTITY to exceptionToStatus. cartId=0 satisfies the URI \d+ requirement but `new CartId(0)` throws CartConstraintException, which used to fall through to a 500. It now surfaces as 422. - Add testSendProcessOrderEmailWithInvalidCartIdReturns422 covering that case. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Thanks @mattgoud — addressed in the last push.
Ready for another look. |
📋 Summary of changesThis PR exposes ⏱️ Estimated review time5–8 minutes — the change is small (two new files, no mappings, no localized fields), but there is a noteworthy architectural question about the HTTP verb choice and a few test gaps to validate. 🎯 Scope
🧱 API Platform / CQRS architecture complianceHTTP verb / operation attribute
URI template
Identifier / DTO property
Command mappingNo Scopes
Exception handlingAll five mapped exceptions appear relevant and use the correct HTTP status codes (404 / 422). ✅ No custom normalizer/processorNone added. ✅ No Value Objects
Multi-shopCart entity is not shop-associated in the DTO sense; 💡 Improvement suggestions
✅ Pre-review checklistURI & routing
Operations & scopes
API Resource properties
CQRS mapping
Forbidden practices (CI-enforced)
Exception handling & validation
Multi-shop
Listing field alignment — N/A (no list endpoint) Integration test
|
mattgoud
left a comment
There was a problem hiding this comment.
Thanks, CartConstraintException is now mapped to 422 and the negative test is in. LGTM.
|
Superseded by #424, which merges this endpoint with the rest of the domain, following the mutualisation asked for by the core team (one PR per domain rather than one per endpoint). The consolidated PR is green and lists what changed for this endpoint on the way in. Closing here to keep the review in one place. |
SendProcessOrderEmailCommandgap:PUT /carts/{cartId}/process-order-emails(scopeorder_write) to send the process-order email to the cart's customer.PUT /carts/{id}/process-order-emails(client grantedorder_write) emails the customer. Covered byCartProcessOrderEmailEndpointTest(which disables real mail sending so the assertion does not depend on an SMTP server).