Skip to content

#26288 Throw an exception when a customer does not exist requests password reset #27269

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

Merged
merged 11 commits into from
Sep 4, 2020

Conversation

Bal2018
Copy link
Contributor

@Bal2018 Bal2018 commented Mar 12, 2020

Description (*)

When a customer (who does not exist) requests a password reset - Magento will now throw an exception error.

Fixed Issues (if relevant)

  1. fixes missing Throw in copy pasted code #26288: missing throw in copy-pasted code

Manual testing scenarios (*)

  1. ...created a customer
  2. ...checked email sent for new customer
  3. ...deleted customer
  4. ...from email clicked on "reset password"
  5. ...when email entered, then error message thrown

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 Mar 12, 2020

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

@lbajsarowicz
Copy link
Contributor

Nice catch. Let me help you with the description, but also I need you to improve code style (Static Tests)

@lbajsarowicz lbajsarowicz changed the title #26288 Will now throw an exception when a customer does not exist wh… #26288 Throw an exception when a customer does not exist requests password reset Mar 12, 2020
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.

Please correct the static tests.
Could you also add Unit Tests for that case, to avoid "losing that" in future*?

  • Test coverage is part of Definition of Done.

@ghost ghost 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 May 6, 2020
@engcom-Echo engcom-Echo self-assigned this May 7, 2020
@engcom-Echo
Copy link
Contributor

I will take care of test coverage.

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.

@engcom-Echo Please review the comments.

Comment on lines 23 to 25
/**
* Test GetCustomerByToken class
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

This annotation is not necessary :-)
You can also use @covers if you really need to express anything as class annotation.

*/
class GetCustomerByTokenTest extends TestCase
{
protected const RESET_PASSWORD = 'resetPassword';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
protected const RESET_PASSWORD = 'resetPassword';
private const RESET_PASSWORD = 'resetPassword';

Unit Tests are not expected to be inherited, use private instead

/**
* @var SearchCriteriaBuilder|MockObject
*/
protected $searchCriteriaBuilderMock;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
protected $searchCriteriaBuilderMock;
private $searchCriteriaBuilderMock;

/**
* @var SearchCriteria|MockObject
*/
protected $searchCriteriaMock;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
protected $searchCriteriaMock;
private $searchCriteriaMock;

/**
* @var CustomerRepositoryInterface|MockObject
*/
protected $customerRepositoryMock;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
protected $customerRepositoryMock;
private $customerRepositoryMock;

Comment on lines 95 to 97
$this->searchResultMock->expects($this->any())
->method('getTotalCount')
->willReturn($totalCount);
Copy link
Contributor

Choose a reason for hiding this comment

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

If it does not matter how many the method is being called, this means it's stub, not mock. Then you should avoid ->expects() at all.

Comment on lines 114 to 116
$this->searchResultMock->expects($this->any())
->method('getTotalCount')
->willReturn($totalCount);
Copy link
Contributor

Choose a reason for hiding this comment

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

If it does not matter how many the method is being called, this means it's stub, not mock. Then you should avoid ->expects() at all.

Comment on lines 108 to 110
/**
* @return void
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/**
* @return void
*/

This provides no additional value

Comment on lines 127 to 129
/**
* @return void
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/**
* @return void
*/

No additional value provided by docblock

Comment on lines 133 to 135
$this->searchResultMock->expects($this->any())
->method('getTotalCount')
->willReturn($totalCount);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$this->searchResultMock->expects($this->any())
->method('getTotalCount')
->willReturn($totalCount);
$this->searchResultMock->method('getTotalCount')->willReturn($totalCount);

If it does not matter how many the method is being called, this means it's stub, not mock. Then you should avoid ->expects() at all.

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.

Awesome. Thank you!

@magento-engcom-team
Copy link
Contributor

Hi @lbajsarowicz, thank you for the review.
ENGCOM-7527 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-Echo engcom-Echo added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label May 7, 2020
@engcom-Alfa engcom-Alfa self-assigned this May 8, 2020
@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

@ghost ghost unassigned engcom-Echo Jun 26, 2020
@engcom-Echo
Copy link
Contributor

@magento run all tests

@engcom-Echo
Copy link
Contributor

Hi @Bal2018 I mistakenly closed PR.

@magento-engcom-team
Copy link
Contributor

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

@engcom-Delta
Copy link
Contributor

✔️ QA passed
Result:
No exception error is shown
image

@engcom-Delta
Copy link
Contributor

Note: Functional Tests EE and Integration Tests are failed

@engcom-Echo
Copy link
Contributor

@magento run all tests

magento-engcom-team pushed a commit that referenced this pull request Sep 4, 2020
@magento-engcom-team magento-engcom-team merged commit ebede20 into magento:2.4-develop Sep 4, 2020
@m2-assistant
Copy link

m2-assistant bot commented Sep 4, 2020

Hi @Bal2018, 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
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Component: Customer Priority: P3 May be fixed according to the position in the backlog. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

missing Throw in copy pasted code
9 participants