@@ -55,8 +55,20 @@ class AuthenticationTest extends \PHPUnit_Framework_TestCase
55
55
*/
56
56
private $ dateTimeMock ;
57
57
58
+ /**
59
+ * @var \Magento\Customer\Model\CustomerAuthUpdate | \PHPUnit_Framework_MockObject_MockObject
60
+ */
61
+ protected $ customerAuthUpdate ;
62
+
63
+ /**
64
+ * @var ObjectManagerHelper
65
+ */
66
+ protected $ objectManager ;
67
+
58
68
protected function setUp ()
59
69
{
70
+ $ this ->objectManager = new ObjectManagerHelper ($ this );
71
+
60
72
$ this ->backendConfigMock = $ this ->getMockBuilder (ConfigInterface::class)
61
73
->disableOriginalConstructor ()
62
74
->setMethods (['getValue ' ])
@@ -98,9 +110,11 @@ protected function setUp()
98
110
false
99
111
);
100
112
101
- $ objectManagerHelper = new ObjectManagerHelper ($ this );
113
+ $ this ->customerAuthUpdate = $ this ->getMockBuilder (\Magento \Customer \Model \CustomerAuthUpdate::class)
114
+ ->disableOriginalConstructor ()
115
+ ->getMock ();
102
116
103
- $ this ->authentication = $ objectManagerHelper ->getObject (
117
+ $ this ->authentication = $ this -> objectManager ->getObject (
104
118
Authentication::class,
105
119
[
106
120
'customerRegistry ' => $ this ->customerRegistryMock ,
@@ -110,6 +124,12 @@ protected function setUp()
110
124
'dateTime ' => $ this ->dateTimeMock ,
111
125
]
112
126
);
127
+
128
+ $ this ->objectManager ->setBackwardCompatibleProperty (
129
+ $ this ->authentication ,
130
+ 'customerAuthUpdate ' ,
131
+ $ this ->customerAuthUpdate
132
+ );
113
133
}
114
134
115
135
public function testProcessAuthenticationFailureLockingIsDisabled ()
@@ -164,16 +184,10 @@ public function testProcessAuthenticationFailureFirstAttempt(
164
184
->method ('retrieveSecureData ' )
165
185
->with ($ customerId )
166
186
->willReturn ($ this ->customerSecureMock );
167
- $ customerMock = $ this ->getMockBuilder (CustomerInterface::class)
168
- ->disableOriginalConstructor ()
169
- ->getMock ();
170
- $ this ->customerRepositoryMock ->expects ($ this ->once ())
171
- ->method ('getById ' )
187
+ $ this ->customerAuthUpdate ->expects ($ this ->once ())
188
+ ->method ('saveAuth ' )
172
189
->with ($ customerId )
173
- ->willReturn ($ customerMock );
174
- $ this ->customerRepositoryMock ->expects ($ this ->once ())
175
- ->method ('save ' )
176
- ->with ($ customerMock );
190
+ ->willReturnSelf ();
177
191
178
192
$ this ->customerSecureMock ->expects ($ this ->once ())->method ('getFailuresNum ' )->willReturn ($ failureNum );
179
193
$ this ->customerSecureMock ->expects ($ this ->once ())
@@ -210,16 +224,10 @@ public function testUnlock()
210
224
->method ('retrieveSecureData ' )
211
225
->with ($ customerId )
212
226
->willReturn ($ this ->customerSecureMock );
213
- $ customerMock = $ this ->getMockBuilder (CustomerInterface::class)
214
- ->disableOriginalConstructor ()
215
- ->getMock ();
216
- $ this ->customerRepositoryMock ->expects ($ this ->once ())
217
- ->method ('getById ' )
227
+ $ this ->customerAuthUpdate ->expects ($ this ->once ())
228
+ ->method ('saveAuth ' )
218
229
->with ($ customerId )
219
- ->willReturn ($ customerMock );
220
- $ this ->customerRepositoryMock ->expects ($ this ->once ())
221
- ->method ('save ' )
222
- ->with ($ customerMock );
230
+ ->willReturnSelf ();
223
231
$ this ->customerSecureMock ->expects ($ this ->once ())->method ('setFailuresNum ' )->with (0 );
224
232
$ this ->customerSecureMock ->expects ($ this ->once ())->method ('setFirstFailure ' )->with (null );
225
233
$ this ->customerSecureMock ->expects ($ this ->once ())->method ('setLockExpires ' )->with (null );
@@ -312,9 +320,10 @@ public function testAuthenticate($result)
312
320
->with ($ customerId )
313
321
->willReturn ($ this ->customerSecureMock );
314
322
315
- $ this ->customerRepositoryMock ->expects ($ this ->once ())
316
- ->method ('save ' )
317
- ->willReturn ($ customerMock );
323
+ $ this ->customerAuthUpdate ->expects ($ this ->once ())
324
+ ->method ('saveAuth ' )
325
+ ->with ($ customerId )
326
+ ->willReturnSelf ();
318
327
319
328
$ this ->setExpectedException (\Magento \Framework \Exception \InvalidEmailOrPasswordException::class);
320
329
$ this ->authentication ->authenticate ($ customerId , $ password );
0 commit comments