Skip to content
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

Open
wants to merge 14 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

mbvb1223
Copy link

@mbvb1223 mbvb1223 commented Oct 27, 2020

Description (*)

Cover AmqpStore module with unit tests

Screenshot from 2020-10-29 09-44-50

Related Pull Requests

Fixed Issues (if relevant)

Manual testing scenarios (*)

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Cover AmqpStore module with unit tests #30671: Cover AmqpStore module with unit tests

@m2-assistant
Copy link

m2-assistant bot commented Oct 27, 2020

Hi @mbvb1223. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

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.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 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

@mbvb1223
Copy link
Author

@magento run all tests

Copy link
Contributor

@lbajsarowicz lbajsarowicz left a 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?

@ghost ghost assigned lbajsarowicz Oct 27, 2020
@mbvb1223 mbvb1223 marked this pull request as draft October 27, 2020 10:23
@mbvb1223
Copy link
Author

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.

@sidolov sidolov added Priority: P3 May be fixed according to the position in the backlog. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Oct 27, 2020
@sidolov
Copy link
Contributor

sidolov commented Oct 27, 2020

@magento create issue

@mbvb1223
Copy link
Author

@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)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


return [
[['store_id' => 123], $storeId, $currentStoreId],
[new AMQPTable(['store_id' => 123]), $storeId, $currentStoreId],
Copy link
Author

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?

https://github.com/mbvb1223/magento2/blob/1e675494b29424bed5d2183e85b4f619cf6e4c47/app/code/Magento/AmqpStore/Plugin/AsynchronousOperations/MassConsumerEnvelopeCallback.php#L75

@mbvb1223 mbvb1223 marked this pull request as ready for review October 29, 2020 03:09
@mbvb1223 mbvb1223 requested a review from lbajsarowicz October 29, 2020 10:42
@slavvka
Copy link
Member

slavvka commented Oct 29, 2020

@magento run all tests

@slavvka
Copy link
Member

slavvka commented Oct 29, 2020

@magento run all tests

Copy link
Contributor

@lbajsarowicz lbajsarowicz left a 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;
Copy link
Contributor

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.

Suggested change
$isProceedCalled = !!$message;
$isProceedCalled = true;

Copy link
Author

@mbvb1223 mbvb1223 Nov 2, 2020

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.

@lbajsarowicz lbajsarowicz added Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: test coverage labels Nov 1, 2020
…ions/MassConsumerEnvelopeCallbackTest.php

Co-authored-by: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com>
@magento-engcom-team
Copy link
Contributor

Hi @lbajsarowicz, thank you for the review.
ENGCOM-8417 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

@mbvb1223 thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

@mbvb1223
Copy link
Author

mbvb1223 commented Nov 7, 2020

@magento run all tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: test coverage Component: AmqpStore Priority: P3 May be fixed according to the position in the backlog. Progress: review Release Line: 2.4 Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

[Issue] Cover AmqpStore module with unit tests
6 participants