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

[GiftMessage] Cover Observer SalesEventOrderItemToQuoteItemObserver by Unit Test #26082

Conversation

edenduong
Copy link
Contributor

Description (*)

Increase Test Coverage by Cover class Magento\GiftMessage\Observer\SalesEventOrderItemToQuoteItemObserver

Fixed Issues (if relevant)

Manual testing scenarios (*)

vendor/bin/phpunit app/code/Magento/GiftMessage/Test/Unit/Observer/SalesEventOrderItemToQuoteItemObserverTest.php

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)

@m2-assistant
Copy link

m2-assistant bot commented Dec 17, 2019

Hi @edenduong. 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

For more details, please, review the Magento Contributor Guide documentation.

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.

I'm really glad with the progress that you've done so far.
Actually - Unit Tests should not contain extra conditional logic.

@ghost ghost assigned lbajsarowicz Dec 17, 2019
@edenduong
Copy link
Contributor Author

Hi @lbajsarowicz : It is ok now. Thank you for your feedback. Please check it again.

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.

Small things that you may change, but it's not crucial.
Once again great contribution. Thank you!

Comment on lines +112 to +122
$this->eventMock->expects($this->atLeastOnce())
->method('getOrderItem')
->willReturn($this->orderItemMock);

$this->orderItemMock->expects($this->atLeastOnce())
->method('getOrder')
->willReturn($this->orderMock);

$this->observerMock->expects($this->atLeastOnce())
->method('getEvent')
->willReturn($this->eventMock);
Copy link
Contributor

Choose a reason for hiding this comment

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

For these three, I'd avoid ->expects part, as someone could want to test the scenario where code does not reach the getOrderItem or getOrder point.

/**
* Test when the order is reorder
*/
public function testReorder()
Copy link
Contributor

Choose a reason for hiding this comment

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

You can do it even more explanatory: testReorderDoesNotCheckIsMessageAllowed

/**
* Test when the order is new reorder and gift message is not allowed
*/
public function testNewOrderWhenGiftMessageIsNotAllowed()
Copy link
Contributor

Choose a reason for hiding this comment

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

Also: testNewOrderWhenGiftMessageIsNotAllowedDoesNotGetQuoteItem to explain what actually is going on inside (It's very useful when you're browsing ouput of phpunit execution)

/**
* Test when the order is new reorder and gift message is allowed
*/
public function testNewOrderWhenGiftMessageIsAllowed()
Copy link
Contributor

Choose a reason for hiding this comment

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

testNewOrderWhenGiftMessageIsAllowedCreatesNewMessage

@magento-engcom-team
Copy link
Contributor

Hi @lbajsarowicz, thank you for the review.
ENGCOM-6496 has been created to process this Pull Request
✳️ @lbajsarowicz, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@engcom-Charlie engcom-Charlie self-assigned this Dec 18, 2019
@engcom-Charlie engcom-Charlie added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Dec 18, 2019
@engcom-Charlie
Copy link
Contributor

✔️ QA Passed

@edenduong
Copy link
Contributor Author

@lbajsarowicz @engcom-Charlie: Could you please add "Test Coverage Award" for this PR :) Thanks :D

@lbajsarowicz
Copy link
Contributor

Sure. I was not into these awards yet. 👍

@magento-engcom-team magento-engcom-team merged commit 85036fa into magento:2.4-develop Dec 19, 2019
@m2-assistant
Copy link

m2-assistant bot commented Dec 19, 2019

Hi @edenduong, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

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

Successfully merging this pull request may close these issues.

None yet

5 participants