@@ -265,7 +265,7 @@ public function testCreateAccountWithPasswordHashWithCustomerWithoutStoreId()
265
265
->method ('getDefaultStore ' )
266
266
->willReturn ($ store );
267
267
$ customer = $ this ->getMockBuilder ('Magento\Customer\Api\Data\CustomerInterface ' )->getMock ();
268
- $ customer ->expects ($ this ->once ())
268
+ $ customer ->expects ($ this ->atLeastOnce ())
269
269
->method ('getId ' )
270
270
->willReturn ($ customerId );
271
271
$ customer ->expects ($ this ->once ())
@@ -341,7 +341,7 @@ public function testCreateAccountWithPasswordHashWithLocalizedException()
341
341
->method ('getDefaultStore ' )
342
342
->willReturn ($ store );
343
343
$ customer = $ this ->getMockBuilder ('Magento\Customer\Api\Data\CustomerInterface ' )->getMock ();
344
- $ customer ->expects ($ this ->once ())
344
+ $ customer ->expects ($ this ->atLeastOnce ())
345
345
->method ('getId ' )
346
346
->willReturn ($ customerId );
347
347
$ customer ->expects ($ this ->once ())
@@ -478,6 +478,61 @@ public function testCreateAccountWithPasswordHashWithAddressException()
478
478
$ this ->accountManagement ->createAccountWithPasswordHash ($ customer , $ hash );
479
479
}
480
480
481
+ /**
482
+ * @expectedException \Magento\Framework\Exception\LocalizedException
483
+ */
484
+ public function testCreateAccountWithPasswordHashWithNewCustomerAndLocalizedException ()
485
+ {
486
+ $ storeId = 1 ;
487
+ $ storeName = 'store_name ' ;
488
+ $ hash = '4nj54lkj5jfi03j49f8bgujfgsd ' ;
489
+
490
+ $ customerMock = $ this ->getMockBuilder ('Magento\Customer\Api\Data\CustomerInterface ' )
491
+ ->getMockForAbstractClass ();
492
+
493
+ $ customerMock ->expects ($ this ->atLeastOnce ())
494
+ ->method ('getId ' )
495
+ ->willReturn (null );
496
+ $ customerMock ->expects ($ this ->atLeastOnce ())
497
+ ->method ('getStoreId ' )
498
+ ->willReturn ($ storeId );
499
+ $ customerMock ->expects ($ this ->once ())
500
+ ->method ('setCreatedIn ' )
501
+ ->with ($ storeName )
502
+ ->willReturnSelf ();
503
+ $ customerMock ->expects ($ this ->once ())
504
+ ->method ('getAddresses ' )
505
+ ->willReturn ([]);
506
+ $ customerMock ->expects ($ this ->once ())
507
+ ->method ('setAddresses ' )
508
+ ->with (null )
509
+ ->willReturnSelf ();
510
+
511
+ $ storeMock = $ this ->getMockBuilder ('Magento\Store\Model\Store ' )
512
+ ->disableOriginalConstructor ()
513
+ ->getMock ();
514
+
515
+ $ storeMock ->expects ($ this ->once ())
516
+ ->method ('getName ' )
517
+ ->willReturn ($ storeName );
518
+
519
+ $ this ->storeManager ->expects ($ this ->once ())
520
+ ->method ('getStore ' )
521
+ ->with ($ storeId )
522
+ ->willReturn ($ storeMock );
523
+
524
+ $ exception = new \Magento \Framework \Exception \LocalizedException (
525
+ new \Magento \Framework \Phrase ('Exception message ' )
526
+ );
527
+ $ this ->customerRepository
528
+ ->expects ($ this ->once ())
529
+ ->method ('save ' )
530
+ ->with ($ customerMock , $ hash )
531
+ ->willThrowException ($ exception );
532
+
533
+ $ this ->accountManagement ->createAccountWithPasswordHash ($ customerMock , $ hash );
534
+ }
535
+
481
536
/**
482
537
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
483
538
*/
0 commit comments