@@ -312,6 +312,7 @@ public function sendNotificationEmailsDataProvider()
312
312
public function testPasswordReminder ()
313
313
{
314
314
$ customerId = 1 ;
315
+ $ customerWebsiteId = 1 ;
315
316
$ customerStoreId = 2 ;
316
317
$ customerEmail = 'email@email.com ' ;
317
318
$ customerData = ['key ' => 'value ' ];
@@ -320,6 +321,8 @@ public function testPasswordReminder()
320
321
$ sender = 'Sender ' ;
321
322
$ senderValues = ['name ' => $ sender , 'email ' => $ sender ];
322
323
324
+ $ storeIds = [1 , 2 ];
325
+
323
326
$ this ->senderResolverMock
324
327
->expects ($ this ->once ())
325
328
->method ('resolve ' )
@@ -328,6 +331,9 @@ public function testPasswordReminder()
328
331
329
332
/** @var CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customer */
330
333
$ customer = $ this ->createMock (CustomerInterface::class);
334
+ $ customer ->expects ($ this ->any ())
335
+ ->method ('getWebsiteId ' )
336
+ ->willReturn ($ customerWebsiteId );
331
337
$ customer ->expects ($ this ->any ())
332
338
->method ('getStoreId ' )
333
339
->willReturn ($ customerStoreId );
@@ -346,10 +352,15 @@ public function testPasswordReminder()
346
352
->method ('getStore ' )
347
353
->willReturn ($ this ->storeMock );
348
354
349
- $ this ->storeManagerMock ->expects ($ this ->at (1 ))
350
- ->method ('getStore ' )
351
- ->with ($ customerStoreId )
352
- ->willReturn ($ this ->storeMock );
355
+ $ websiteMock = $ this ->createPartialMock (\Magento \Store \Model \Website::class, ['getStoreIds ' ]);
356
+ $ websiteMock ->expects ($ this ->any ())
357
+ ->method ('getStoreIds ' )
358
+ ->willReturn ($ storeIds );
359
+
360
+ $ this ->storeManagerMock ->expects ($ this ->any ())
361
+ ->method ('getWebsite ' )
362
+ ->with ($ customerWebsiteId )
363
+ ->willReturn ($ websiteMock );
353
364
354
365
$ this ->customerRegistryMock ->expects ($ this ->once ())
355
366
->method ('retrieveSecureData ' )
@@ -396,6 +407,99 @@ public function testPasswordReminder()
396
407
$ this ->model ->passwordReminder ($ customer );
397
408
}
398
409
410
+ /**
411
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
412
+ */
413
+ public function testPasswordReminderCustomerWithoutStoreId ()
414
+ {
415
+ $ customerId = 1 ;
416
+ $ customerWebsiteId = 1 ;
417
+ $ customerStoreId = null ;
418
+ $ customerEmail = 'email@email.com ' ;
419
+ $ customerData = ['key ' => 'value ' ];
420
+ $ customerName = 'Customer Name ' ;
421
+ $ templateIdentifier = 'Template Identifier ' ;
422
+ $ sender = 'Sender ' ;
423
+ $ senderValues = ['name ' => $ sender , 'email ' => $ sender ];
424
+ $ storeIds = [1 , 2 ];
425
+ $ defaultStoreId = reset ($ storeIds );
426
+ $ this ->senderResolverMock
427
+ ->expects ($ this ->once ())
428
+ ->method ('resolve ' )
429
+ ->with ($ sender , $ defaultStoreId )
430
+ ->willReturn ($ senderValues );
431
+ /** @var CustomerInterface | \PHPUnit_Framework_MockObject_MockObject $customer */
432
+ $ customer = $ this ->createMock (CustomerInterface::class);
433
+ $ customer ->expects ($ this ->any ())
434
+ ->method ('getWebsiteId ' )
435
+ ->willReturn ($ customerWebsiteId );
436
+ $ customer ->expects ($ this ->any ())
437
+ ->method ('getStoreId ' )
438
+ ->willReturn ($ customerStoreId );
439
+ $ customer ->expects ($ this ->any ())
440
+ ->method ('getId ' )
441
+ ->willReturn ($ customerId );
442
+ $ customer ->expects ($ this ->any ())
443
+ ->method ('getEmail ' )
444
+ ->willReturn ($ customerEmail );
445
+ $ this ->storeMock ->expects ($ this ->any ())
446
+ ->method ('getId ' )
447
+ ->willReturn ($ defaultStoreId );
448
+ $ this ->storeManagerMock ->expects ($ this ->at (0 ))
449
+ ->method ('getStore ' )
450
+ ->willReturn ($ this ->storeMock );
451
+ $ this ->storeManagerMock ->expects ($ this ->at (1 ))
452
+ ->method ('getStore ' )
453
+ ->with ($ defaultStoreId )
454
+ ->willReturn ($ this ->storeMock );
455
+ $ websiteMock = $ this ->createPartialMock (\Magento \Store \Model \Website::class, ['getStoreIds ' ]);
456
+ $ websiteMock ->expects ($ this ->any ())
457
+ ->method ('getStoreIds ' )
458
+ ->willReturn ($ storeIds );
459
+ $ this ->storeManagerMock ->expects ($ this ->any ())
460
+ ->method ('getWebsite ' )
461
+ ->with ($ customerWebsiteId )
462
+ ->willReturn ($ websiteMock );
463
+
464
+ $ this ->customerRegistryMock ->expects ($ this ->once ())
465
+ ->method ('retrieveSecureData ' )
466
+ ->with ($ customerId )
467
+ ->willReturn ($ this ->customerSecureMock );
468
+ $ this ->dataProcessorMock ->expects ($ this ->once ())
469
+ ->method ('buildOutputDataArray ' )
470
+ ->with ($ customer , CustomerInterface::class)
471
+ ->willReturn ($ customerData );
472
+ $ this ->customerViewHelperMock ->expects ($ this ->any ())
473
+ ->method ('getCustomerName ' )
474
+ ->with ($ customer )
475
+ ->willReturn ($ customerName );
476
+ $ this ->customerSecureMock ->expects ($ this ->once ())
477
+ ->method ('addData ' )
478
+ ->with ($ customerData )
479
+ ->willReturnSelf ();
480
+ $ this ->customerSecureMock ->expects ($ this ->once ())
481
+ ->method ('setData ' )
482
+ ->with ('name ' , $ customerName )
483
+ ->willReturnSelf ();
484
+ $ this ->scopeConfigMock ->expects ($ this ->at (0 ))
485
+ ->method ('getValue ' )
486
+ ->with (EmailNotification::XML_PATH_REMIND_EMAIL_TEMPLATE , ScopeInterface::SCOPE_STORE , $ defaultStoreId )
487
+ ->willReturn ($ templateIdentifier );
488
+ $ this ->scopeConfigMock ->expects ($ this ->at (1 ))
489
+ ->method ('getValue ' )
490
+ ->with (EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY , ScopeInterface::SCOPE_STORE , $ defaultStoreId )
491
+ ->willReturn ($ sender );
492
+ $ this ->mockDefaultTransportBuilder (
493
+ $ templateIdentifier ,
494
+ $ defaultStoreId ,
495
+ $ senderValues ,
496
+ $ customerEmail ,
497
+ $ customerName ,
498
+ ['customer ' => $ this ->customerSecureMock , 'store ' => $ this ->storeMock ]
499
+ );
500
+ $ this ->model ->passwordReminder ($ customer );
501
+ }
502
+
399
503
/**
400
504
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
401
505
*/
0 commit comments