-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cover AmqpStore module with unit tests #30660
base: 2.4-develop
Are you sure you want to change the base?
Cover AmqpStore module with unit tests #30660
Conversation
Hi @mbvb1223. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Thank you for your input. Could you also cover other scenarios when $proceed
is not called?
Sure, I am adding more test cases to cover 100% code for this module. |
@magento create issue |
@magento run Static Tests |
@@ -83,9 +83,6 @@ public function beforeEnqueue(SubjectExchange $subject, $topic, array $envelopes | |||
$updatedEnvelopes = []; | |||
foreach ($envelopes as $envelope) { | |||
$properties = $envelope->getProperties(); | |||
if (!isset($properties)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$properties is always array so I removed this logic
https://github.com/mbvb1223/magento2/blob/5d2f2e87a6f23db0483a53d445bbf055826c022a/lib/internal/Magento/Framework/MessageQueue/Envelope.php#L29
|
||
return [ | ||
[['store_id' => 123], $storeId, $currentStoreId], | ||
[new AMQPTable(['store_id' => 123]), $storeId, $currentStoreId], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a new object AMQPTable because I could not create a mock and mock for the final method "getNativeData"
Do you have any suggestions for this?
@magento run all tests |
@magento run all tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️ Thank you for your contribution. In general, your changes are correct. Please consider applying the suggested comments.
|
||
$isProceedCalled = false; | ||
$proceed = function ($message) use (&$isProceedCalled) { | ||
$isProceedCalled = !!$message; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think !!$message
is a good option for marking if $proceed
was called. Simply true
is good enough.
$isProceedCalled = !!$message; | |
$isProceedCalled = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestion.
In this case, if I use $isProceedCalled = true;
then $message is not used anywhere and can be warned a coding convention (and maybe I need to use // @SuppressWarnings(PHPMD.UnusedFormalParameter)
).
Also, I want to confirm that $message
was put as a parameter on $proceed($message);
Ak, maybe it is better if we change to $isProceedCalled = ($message instanceof EnvelopeInterface);
Haha, it is the same :D
I will leave the code as-is.
...gento/AmqpStore/Test/Unit/Plugin/AsynchronousOperations/MassConsumerEnvelopeCallbackTest.php
Outdated
Show resolved
Hide resolved
...gento/AmqpStore/Test/Unit/Plugin/AsynchronousOperations/MassConsumerEnvelopeCallbackTest.php
Show resolved
Hide resolved
…ions/MassConsumerEnvelopeCallbackTest.php Co-authored-by: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com>
Hi @lbajsarowicz, thank you for the review. |
@magento run all tests |
Description (*)
Cover AmqpStore module with unit tests
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)
Resolved issues: