@@ -318,7 +318,7 @@ public function testCreateAccountWithPasswordHashWithCustomerWithoutStoreId()
318318 ->method ('getId ' )
319319 ->willReturn ($ defaultStoreId );
320320 $ website = $ this ->getMockBuilder (\Magento \Store \Model \Website::class)->disableOriginalConstructor ()->getMock ();
321- $ website ->expects ($ this ->once ())
321+ $ website ->expects ($ this ->atLeastOnce ())
322322 ->method ('getStoreIds ' )
323323 ->willReturn ([1 , 2 , 3 ]);
324324 $ website ->expects ($ this ->once ())
@@ -354,7 +354,7 @@ public function testCreateAccountWithPasswordHashWithCustomerWithoutStoreId()
354354 ->with ($ customerEmail )
355355 ->willReturn ($ customer );
356356 $ this ->share
357- ->expects ($ this ->once ())
357+ ->expects ($ this ->atLeastOnce ())
358358 ->method ('isWebsiteScope ' )
359359 ->willReturn (true );
360360 $ this ->storeManager
@@ -545,6 +545,7 @@ public function testCreateAccountWithPasswordHashWithNewCustomerAndLocalizedExce
545545 {
546546 $ storeId = 1 ;
547547 $ storeName = 'store_name ' ;
548+ $ websiteId = 1 ;
548549 $ hash = '4nj54lkj5jfi03j49f8bgujfgsd ' ;
549550
550551 $ customerMock = $ this ->getMockBuilder (\Magento \Customer \Api \Data \CustomerInterface::class)
@@ -556,6 +557,9 @@ public function testCreateAccountWithPasswordHashWithNewCustomerAndLocalizedExce
556557 $ customerMock ->expects ($ this ->atLeastOnce ())
557558 ->method ('getStoreId ' )
558559 ->willReturn ($ storeId );
560+ $ customerMock ->expects ($ this ->atLeastOnce ())
561+ ->method ('getWebsiteId ' )
562+ ->willReturn ($ websiteId );
559563 $ customerMock ->expects ($ this ->once ())
560564 ->method ('setCreatedIn ' )
561565 ->with ($ storeName )
@@ -567,6 +571,19 @@ public function testCreateAccountWithPasswordHashWithNewCustomerAndLocalizedExce
567571 ->method ('setAddresses ' )
568572 ->with (null )
569573 ->willReturnSelf ();
574+ $ this ->share
575+ ->expects ($ this ->once ())
576+ ->method ('isWebsiteScope ' )
577+ ->willReturn (true );
578+ $ website = $ this ->getMockBuilder (\Magento \Store \Model \Website::class)->disableOriginalConstructor ()->getMock ();
579+ $ website ->expects ($ this ->once ())
580+ ->method ('getStoreIds ' )
581+ ->willReturn ([1 , 2 , 3 ]);
582+ $ this ->storeManager
583+ ->expects ($ this ->atLeastOnce ())
584+ ->method ('getWebsite ' )
585+ ->with ($ websiteId )
586+ ->willReturn ($ website );
570587
571588 $ storeMock = $ this ->getMockBuilder (\Magento \Store \Model \Store::class)
572589 ->disableOriginalConstructor ()
@@ -576,7 +593,7 @@ public function testCreateAccountWithPasswordHashWithNewCustomerAndLocalizedExce
576593 ->method ('getName ' )
577594 ->willReturn ($ storeName );
578595
579- $ this ->storeManager ->expects ($ this ->exactly (2 ))
596+ $ this ->storeManager ->expects ($ this ->exactly (1 ))
580597 ->method ('getStore ' )
581598 ->with ($ storeId )
582599 ->willReturn ($ storeMock );
@@ -1720,7 +1737,7 @@ public function testCreateAccountWithPasswordHashForGuest()
17201737 $ customerMock ->expects ($ this ->exactly (3 ))
17211738 ->method ('getStoreId ' )
17221739 ->willReturn (null );
1723- $ customerMock ->expects ($ this ->exactly (2 ))
1740+ $ customerMock ->expects ($ this ->exactly (3 ))
17241741 ->method ('getWebsiteId ' )
17251742 ->willReturn (null );
17261743 $ customerMock ->expects ($ this ->once ())
@@ -1752,6 +1769,9 @@ public function testCreateAccountWithPasswordHashForGuest()
17521769 $ this ->accountManagement ->createAccountWithPasswordHash ($ customerMock , $ hash );
17531770 }
17541771
1772+ /**
1773+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1774+ */
17551775 public function testCreateAccountWithPasswordHashWithCustomerAddresses ()
17561776 {
17571777 $ websiteId = 1 ;
@@ -1846,6 +1866,19 @@ public function testCreateAccountWithPasswordHashWithCustomerAddresses()
18461866 ->expects ($ this ->atLeastOnce ())
18471867 ->method ('getStore ' )
18481868 ->willReturn ($ store );
1869+ $ this ->share
1870+ ->expects ($ this ->once ())
1871+ ->method ('isWebsiteScope ' )
1872+ ->willReturn (true );
1873+ $ website = $ this ->getMockBuilder (\Magento \Store \Model \Website::class)->disableOriginalConstructor ()->getMock ();
1874+ $ website ->expects ($ this ->once ())
1875+ ->method ('getStoreIds ' )
1876+ ->willReturn ([1 , 2 , 3 ]);
1877+ $ this ->storeManager
1878+ ->expects ($ this ->atLeastOnce ())
1879+ ->method ('getWebsite ' )
1880+ ->with ($ websiteId )
1881+ ->willReturn ($ website );
18491882
18501883 $ this ->assertSame ($ customer , $ this ->accountManagement ->createAccountWithPasswordHash ($ customer , $ hash ));
18511884 }
@@ -1976,4 +2009,39 @@ public function testCreateAccountUnexpectedValueException(): void
19762009
19772010 $ this ->accountManagement ->createAccount ($ customer );
19782011 }
2012+
2013+ /**
2014+ * @expectedException \Magento\Framework\Exception\LocalizedException
2015+ */
2016+ public function testCreateAccountWithStoreNotInWebsite ()
2017+ {
2018+ $ storeId = 1 ;
2019+ $ websiteId = 1 ;
2020+ $ hash = '4nj54lkj5jfi03j49f8bgujfgsd ' ;
2021+ $ customerMock = $ this ->getMockBuilder (\Magento \Customer \Api \Data \CustomerInterface::class)
2022+ ->getMockForAbstractClass ();
2023+ $ customerMock ->expects ($ this ->atLeastOnce ())
2024+ ->method ('getId ' )
2025+ ->willReturn (null );
2026+ $ customerMock ->expects ($ this ->atLeastOnce ())
2027+ ->method ('getStoreId ' )
2028+ ->willReturn ($ storeId );
2029+ $ customerMock ->expects ($ this ->atLeastOnce ())
2030+ ->method ('getWebsiteId ' )
2031+ ->willReturn ($ websiteId );
2032+ $ this ->share
2033+ ->expects ($ this ->once ())
2034+ ->method ('isWebsiteScope ' )
2035+ ->willReturn (true );
2036+ $ website = $ this ->getMockBuilder (\Magento \Store \Model \Website::class)->disableOriginalConstructor ()->getMock ();
2037+ $ website ->expects ($ this ->once ())
2038+ ->method ('getStoreIds ' )
2039+ ->willReturn ([2 , 3 ]);
2040+ $ this ->storeManager
2041+ ->expects ($ this ->atLeastOnce ())
2042+ ->method ('getWebsite ' )
2043+ ->with ($ websiteId )
2044+ ->willReturn ($ website );
2045+ $ this ->accountManagement ->createAccountWithPasswordHash ($ customerMock , $ hash );
2046+ }
19792047}
0 commit comments