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