Skip to content

Commit 9992c0e

Browse files
committed
refactor code to pass review
1 parent 7534f33 commit 9992c0e

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,19 @@
1414
use Magento\Captcha\Model\DefaultModel;
1515
use Magento\Customer\Api\Data\CustomerInterface as CustomerData;
1616
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
17+
use PHPUnit\Framework\TestCase;
1718

18-
/**
19-
* Test class to cover \Magento\Captcha\CustomerData\Captcha
20-
*
21-
* Class \Magento\Captcha\Test\Unit\CustomerData\CaptchaTest
22-
*/
23-
class CaptchaTest extends \PHPUnit\Framework\TestCase
19+
class CaptchaTest extends TestCase
2420
{
2521
/**
2622
* @var CaptchaHelper|\PHPUnit_Framework_MockObject_MockObject
2723
*/
28-
private $helper;
24+
private $helperMock;
2925

3026
/**
3127
* @var CustomerSession|\PHPUnit_Framework_MockObject_MockObject
3228
*/
33-
private $customerSession;
34-
35-
/**
36-
* @var CustomerData|\PHPUnit_Framework_MockObject_MockObject
37-
*/
38-
private $customerData;
29+
private $customerSessionMock;
3930

4031
/**
4132
* @var Captcha
@@ -57,18 +48,18 @@ class CaptchaTest extends \PHPUnit\Framework\TestCase
5748
*/
5849
protected function setUp()
5950
{
60-
$this->helper = $this->createMock(CaptchaHelper::class);
61-
$this->customerSession = $this->createMock(CustomerSession::class);
51+
$this->helperMock = $this->createMock(CaptchaHelper::class);
52+
$this->customerSessionMock = $this->createMock(CustomerSession::class);
6253
$this->formIds = [
6354
'user_login'
6455
];
6556
$this->objectManagerHelper = new ObjectManagerHelper($this);
6657
$this->model = $this->objectManagerHelper->getObject(
6758
Captcha::class,
6859
[
69-
'helper' => $this->helper,
60+
'helper' => $this->helperMock,
7061
'formIds' => $this->formIds,
71-
'customerSession' => $this->customerSession
62+
'customerSession' => $this->customerSessionMock
7263
]
7364
);
7465
}
@@ -83,15 +74,15 @@ public function testGetSectionDataWhenLoginAndRequireCaptcha()
8374
$userLoginModel = $this->createMock(DefaultModel::class);
8475
$userLoginModel->expects($this->any())->method('isRequired')->with($emailLogin)
8576
->willReturn(true);
86-
$this->helper->expects($this->any())->method('getCaptcha')->with('user_login')->willReturn($userLoginModel);
77+
$this->helperMock->expects($this->any())->method('getCaptcha')->with('user_login')->willReturn($userLoginModel);
8778

88-
$this->customerSession->expects($this->any())->method('isLoggedIn')
79+
$this->customerSessionMock->expects($this->any())->method('isLoggedIn')
8980
->willReturn(true);
9081

91-
$this->customerData = $this->createMock(CustomerData::class);
92-
$this->customerData->expects($this->any())->method('getEmail')->willReturn($emailLogin);
93-
$this->customerSession->expects($this->any())->method('getCustomerData')
94-
->willReturn($this->customerData);
82+
$customerDataMock = $this->createMock(CustomerData::class);
83+
$customerDataMock->expects($this->any())->method('getEmail')->willReturn($emailLogin);
84+
$this->customerSessionMock->expects($this->any())->method('getCustomerData')
85+
->willReturn($customerDataMock);
9586

9687
/* Assert to test */
9788
$this->assertEquals(

0 commit comments

Comments
 (0)