@@ -200,6 +200,7 @@ private function assertSuccessSessionMessage(string $email): void
200
200
*/
201
201
public function testResetLinkSentAfterForgotPassword (): void
202
202
{
203
+ // Getting and asserting actual default expiration period
203
204
$ defaultExpirationPeriod = 2 ;
204
205
$ actualExpirationPeriod = (int ) $ this ->scopeConfig ->getValue (
205
206
'customer/password/reset_link_expiration_period ' ,
@@ -210,6 +211,7 @@ public function testResetLinkSentAfterForgotPassword(): void
210
211
$ actualExpirationPeriod
211
212
);
212
213
214
+ // Updating expiration period
213
215
$ this ->resourceConfig ->saveConfig (
214
216
'customer/password/reset_link_expiration_period ' ,
215
217
1 ,
@@ -222,6 +224,7 @@ public function testResetLinkSentAfterForgotPassword(): void
222
224
$ this ->getRequest ()->setPostValue (['email ' => $ email ]);
223
225
$ this ->getRequest ()->setMethod (HttpRequest::METHOD_POST );
224
226
227
+ // Click on the forgot password
225
228
$ this ->dispatch ('customer/account/forgotPasswordPost ' );
226
229
$ this ->assertRedirect ($ this ->stringContains ('customer/account/ ' ));
227
230
$ this ->assertSessionMessages (
@@ -247,6 +250,7 @@ public function testResetLinkSentAfterForgotPassword(): void
247
250
$ token = $ customerData ->getRpToken ();
248
251
$ customerId = $ customerData ->getId ();
249
252
253
+ // Asserting mail contains reset link
250
254
$ this ->assertEquals (
251
255
1 ,
252
256
Xpath::getElementsCountForXpath (
@@ -296,6 +300,7 @@ public function testResetLinkExpirationByTimeout(): void
296
300
$ session ->setRpToken ($ token );
297
301
$ session ->setRpCustomerId ($ customerId );
298
302
303
+ // Click on the reset password link
299
304
$ this ->getRequest ()->setParam ('token ' , $ token )->setParam ('id ' , $ customerId );
300
305
$ this ->dispatch ('customer/account/createPassword ' );
301
306
$ this ->assertSessionMessages (
@@ -307,6 +312,7 @@ public function testResetLinkExpirationByTimeout(): void
307
312
->sub (\DateInterval::createFromDateString ('2 hour ' ))
308
313
->format (DateTime::DATETIME_PHP_FORMAT );
309
314
315
+ // Updating reTokenCreatedAt field
310
316
$ customerSecure = $ customerRegistry ->retrieveSecureData ($ customerId );
311
317
$ customerSecure ->setRpTokenCreatedAt ($ rpTokenCreatedAt );
312
318
$ this ->customerResource ->save ($ customerData );
@@ -315,6 +321,7 @@ public function testResetLinkExpirationByTimeout(): void
315
321
$ this ->getRequest ()->setMethod (HttpRequest::METHOD_GET );
316
322
$ this ->dispatch ('customer/account/createPassword ' );
317
323
324
+ // Asserting failed message after link expire
318
325
$ this ->assertSessionMessages (
319
326
$ this ->equalTo (['Your password reset link has expired. ' ]),
320
327
MessageInterface::TYPE_ERROR
0 commit comments