Skip to content

Unit test for Magento\Reports\Observer\CheckoutCartAddProductObserver #26579

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

Conversation

karyna-t
Copy link
Contributor

Description (*)

Covers Magento\Reports\Observer\CheckoutCartAddProductObserver with a unit test.

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 Jan 29, 2020

Hi @karyna-tsymbal-atwix. 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.

@magento-engcom-team magento-engcom-team added Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner labels Jan 29, 2020
@aleron75 aleron75 added Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: test coverage labels Jan 30, 2020
@magento-engcom-team
Copy link
Contributor

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

@engcom-Bravo
Copy link
Contributor

✔️ QA Passed

The test is added and passes
CheckoutCartAddProductObserverTest

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.

@karyna-tsymbal-atwix I love the progress that you've made with Tests!
Just a few hints to your tests and then this will be another example of your perfect work! 👍

use PHPUnit\Framework\TestCase;

/**
* Unit Test for @see CheckoutCartAddProductObserver
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the point of adding @see there? :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, it's my old habit :) I've replaced it with a name of the class. Is that ok?

/**
* The case when event has to be successfully saved
*/
public function testExecute()
Copy link
Contributor

Choose a reason for hiding this comment

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

Give more meaningful name to test.
testExecute is bad practice, as it should explain what we expect to be tested.
For example: testExecuteExpectsSaveCalledOnceForNewProduct()

*/
private function checkOriginalMethodIsNeverExecuted()
{
$this->eventSaverMock->expects($this->never())
Copy link
Contributor

Choose a reason for hiding this comment

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

That actually does not exceeds 80 characters in a row, so you can keep that single-line.

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.

Thanks for your contribution

@magento-engcom-team
Copy link
Contributor

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

@engcom-Bravo
Copy link
Contributor

✔️ QA Passed

@engcom-Charlie
Copy link
Contributor

engcom-Charlie commented Feb 3, 2020

Failures of functional tests, not related to the changes in this PR, tests failing on 2.4-develop branch
image
image

@lbajsarowicz
Copy link
Contributor

This is actually addressed. Waiting for fixes to be handled.
#26608

@magento-engcom-team magento-engcom-team merged commit a183437 into magento:2.4-develop Feb 9, 2020
@m2-assistant
Copy link

m2-assistant bot commented Feb 9, 2020

Hi @karyna-tsymbal-atwix, 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.

@karyna-t karyna-t deleted the unit-test-reports-checkoutCartAddProductObserver branch August 6, 2021 19:50
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 Component: Reports Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner Progress: accept Release Line: 2.4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants