-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Unit Test to cover class \Magento\Captcha\CustomerData\Captcha #25686
Unit Test to cover class \Magento\Captcha\CustomerData\Captcha #25686
Conversation
Hi @edenduong. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
class CaptchaTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var CaptchaHelper | \PHPUnit_Framework_MockObject_MockObject |
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.
Unnecessary spaces
/** | ||
* Test getSectionData() when user is login and require captcha | ||
*/ | ||
public function testGetSectionData() |
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.
The test name should be more explanatory, current is too generic.
Hi @lbajsarowicz: I have changed it. Please check it again. |
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.
Several changes, in my opinion, are still necessary. Not crucial ones, but still something that needs to be done.
$this->customerSession->expects($this->any())->method('isLoggedIn') | ||
->willReturn(true); | ||
|
||
$this->customerData = $this->createMock(CustomerData::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.
If you are instantiating mock there and using only for this test, use local variable instead of class property.
* | ||
* Class \Magento\Captcha\Test\Unit\CustomerData\CaptchaTest | ||
*/ | ||
class CaptchaTest extends \PHPUnit\Framework\TestCase |
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.
Import the class.
/** | ||
* Test class to cover \Magento\Captcha\CustomerData\Captcha | ||
* | ||
* Class \Magento\Captcha\Test\Unit\CustomerData\CaptchaTest |
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 line is completely redundant.
/** | ||
* @var CaptchaHelper|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $helper; |
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.
It's highly recommended to mark that it's still mock, not the real implementation by renaming the property to helperMock
/** | ||
* @var CustomerSession|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $customerSession; |
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.
Append Mock
to name to mark that's not real implementation.
/** | ||
* @var CustomerData|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $customerData; |
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.
Append Mock
to name to mark that's not real implementation.
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.
Now it's fine. Thanks for your contribution!
Hi @lbajsarowicz, thank you for the review.
|
✔️ QA Passed |
Hi @edenduong, thank you for your contribution! |
Description (*)
Unit Test to cover class \Magento\Captcha\CustomerData\Captcha
Fixed Issues (if relevant)
Manual testing scenarios (*)
Covered by Unit Test
Questions or comments
Contribution checklist (*)