14
14
use Magento \Captcha \Model \DefaultModel ;
15
15
use Magento \Customer \Api \Data \CustomerInterface as CustomerData ;
16
16
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
17
+ use PHPUnit \Framework \TestCase ;
17
18
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
24
20
{
25
21
/**
26
22
* @var CaptchaHelper|\PHPUnit_Framework_MockObject_MockObject
27
23
*/
28
- private $ helper ;
24
+ private $ helperMock ;
29
25
30
26
/**
31
27
* @var CustomerSession|\PHPUnit_Framework_MockObject_MockObject
32
28
*/
33
- private $ customerSession ;
34
-
35
- /**
36
- * @var CustomerData|\PHPUnit_Framework_MockObject_MockObject
37
- */
38
- private $ customerData ;
29
+ private $ customerSessionMock ;
39
30
40
31
/**
41
32
* @var Captcha
@@ -57,18 +48,18 @@ class CaptchaTest extends \PHPUnit\Framework\TestCase
57
48
*/
58
49
protected function setUp ()
59
50
{
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);
62
53
$ this ->formIds = [
63
54
'user_login '
64
55
];
65
56
$ this ->objectManagerHelper = new ObjectManagerHelper ($ this );
66
57
$ this ->model = $ this ->objectManagerHelper ->getObject (
67
58
Captcha::class,
68
59
[
69
- 'helper ' => $ this ->helper ,
60
+ 'helper ' => $ this ->helperMock ,
70
61
'formIds ' => $ this ->formIds ,
71
- 'customerSession ' => $ this ->customerSession
62
+ 'customerSession ' => $ this ->customerSessionMock
72
63
]
73
64
);
74
65
}
@@ -83,15 +74,15 @@ public function testGetSectionDataWhenLoginAndRequireCaptcha()
83
74
$ userLoginModel = $ this ->createMock (DefaultModel::class);
84
75
$ userLoginModel ->expects ($ this ->any ())->method ('isRequired ' )->with ($ emailLogin )
85
76
->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 );
87
78
88
- $ this ->customerSession ->expects ($ this ->any ())->method ('isLoggedIn ' )
79
+ $ this ->customerSessionMock ->expects ($ this ->any ())->method ('isLoggedIn ' )
89
80
->willReturn (true );
90
81
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 );
95
86
96
87
/* Assert to test */
97
88
$ this ->assertEquals (
0 commit comments