-
Notifications
You must be signed in to change notification settings - Fork 9.4k
#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
#26288 Throw an exception when a customer does not exist requests password reset #27269
Conversation
…ist who wants to reset password
Hi @Bal2018. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
Nice catch. Let me help you with the description, but also I need you to improve code style (Static 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.
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.
I will take care of test coverage. |
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.
@engcom-Echo Please review the comments.
/** | ||
* Test GetCustomerByToken class | ||
*/ |
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.
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'; |
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.
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; |
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.
protected $searchCriteriaBuilderMock; | |
private $searchCriteriaBuilderMock; |
/** | ||
* @var SearchCriteria|MockObject | ||
*/ | ||
protected $searchCriteriaMock; |
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.
protected $searchCriteriaMock; | |
private $searchCriteriaMock; |
/** | ||
* @var CustomerRepositoryInterface|MockObject | ||
*/ | ||
protected $customerRepositoryMock; |
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.
protected $customerRepositoryMock; | |
private $customerRepositoryMock; |
$this->searchResultMock->expects($this->any()) | ||
->method('getTotalCount') | ||
->willReturn($totalCount); |
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.
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.
$this->searchResultMock->expects($this->any()) | ||
->method('getTotalCount') | ||
->willReturn($totalCount); |
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.
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.
/** | ||
* @return void | ||
*/ |
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.
/** | |
* @return void | |
*/ |
This provides no additional value
/** | ||
* @return void | ||
*/ |
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.
/** | |
* @return void | |
*/ |
No additional value provided by docblock
$this->searchResultMock->expects($this->any()) | ||
->method('getTotalCount') | ||
->willReturn($totalCount); |
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.
$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.
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.
Awesome. Thank you!
Hi @lbajsarowicz, thank you for the review.
|
✔️ QA Passed |
@magento run all tests |
Hi @Bal2018 I mistakenly closed PR. |
Hi @sidolov, thank you for the review. |
Note: Functional Tests EE and Integration Tests are failed |
@magento run all tests |
… requests password reset #27269
Hi @Bal2018, thank you for your contribution! |
Description (*)
When a customer (who does not exist) requests a password reset - Magento will now throw an exception error.
Fixed Issues (if relevant)
throw
in copy-pasted codeManual testing scenarios (*)
Questions or comments
Contribution checklist (*)