@@ -472,7 +472,7 @@ public function testCreateAccountWithPasswordHashWithCustomerWithoutStoreId(): v
472
472
$ website ->expects ($ this ->atLeastOnce ())
473
473
->method ('getStoreIds ' )
474
474
->willReturn ([1 , 2 , 3 ]);
475
- $ website ->expects ($ this ->once ( ))
475
+ $ website ->expects ($ this ->atMost ( 2 ))
476
476
->method ('getDefaultStore ' )
477
477
->willReturn ($ store );
478
478
$ customer = $ this ->getMockBuilder (Customer::class)
@@ -551,7 +551,7 @@ public function testCreateAccountWithPasswordHashWithLocalizedException(): void
551
551
->getMock ();
552
552
$ website ->method ('getStoreIds ' )
553
553
->willReturn ([1 , 2 , 3 ]);
554
- $ website ->expects ($ this ->once ( ))
554
+ $ website ->expects ($ this ->atMost ( 2 ))
555
555
->method ('getDefaultStore ' )
556
556
->willReturn ($ store );
557
557
$ customer = $ this ->getMockBuilder (Customer::class)
@@ -633,7 +633,7 @@ public function testCreateAccountWithPasswordHashWithAddressException(): void
633
633
->getMock ();
634
634
$ website ->method ('getStoreIds ' )
635
635
->willReturn ([1 , 2 , 3 ]);
636
- $ website ->expects ($ this ->once ( ))
636
+ $ website ->expects ($ this ->atMost ( 2 ))
637
637
->method ('getDefaultStore ' )
638
638
->willReturn ($ store );
639
639
$ customer = $ this ->getMockBuilder (Customer::class)
@@ -2598,4 +2598,55 @@ public function testValidateCustomerStoreIdByWebsiteIdException(): void
2598
2598
2599
2599
$ this ->assertTrue ($ this ->accountManagement ->validateCustomerStoreIdByWebsiteId ($ customerMock ));
2600
2600
}
2601
+
2602
+ /**
2603
+ * @return void
2604
+ * @throws LocalizedException
2605
+ */
2606
+ public function testCompanyAdminWebsiteDoesNotHaveStore (): void
2607
+ {
2608
+ $ this ->expectException (LocalizedException::class);
2609
+ $ this ->expectExceptionMessage ('The store view is not in the associated website. ' );
2610
+
2611
+ $ websiteId = 1 ;
2612
+ $ customerId = 1 ;
2613
+ $ customerEmail = 'email@email.com ' ;
2614
+ $ hash = '4nj54lkj5jfi03j49f8bgujfgsd ' ;
2615
+
2616
+ $ website = $ this ->getMockBuilder (Website::class)
2617
+ ->disableOriginalConstructor ()
2618
+ ->getMock ();
2619
+ $ website ->method ('getStoreIds ' )
2620
+ ->willReturn ([]);
2621
+ $ website ->expects ($ this ->atMost (1 ))
2622
+ ->method ('getDefaultStore ' )
2623
+ ->willReturn (null );
2624
+ $ customer = $ this ->getMockBuilder (Customer::class)
2625
+ ->disableOriginalConstructor ()
2626
+ ->getMock ();
2627
+ $ customer ->expects ($ this ->atLeastOnce ())
2628
+ ->method ('getId ' )
2629
+ ->willReturn ($ customerId );
2630
+ $ customer ->expects ($ this ->once ())
2631
+ ->method ('getEmail ' )
2632
+ ->willReturn ($ customerEmail );
2633
+ $ customer ->expects ($ this ->atLeastOnce ())
2634
+ ->method ('getWebsiteId ' )
2635
+ ->willReturn ($ websiteId );
2636
+ $ customer ->method ('getStoreId ' )
2637
+ ->willReturnOnConsecutiveCalls (null , null , 1 );
2638
+ $ this ->customerRepository
2639
+ ->expects ($ this ->once ())
2640
+ ->method ('get ' )
2641
+ ->with ($ customerEmail )
2642
+ ->willReturn ($ customer );
2643
+ $ this ->share ->method ('isWebsiteScope ' )
2644
+ ->willReturn (true );
2645
+ $ this ->storeManager
2646
+ ->expects ($ this ->atLeastOnce ())
2647
+ ->method ('getWebsite ' )
2648
+ ->with ($ websiteId )
2649
+ ->willReturn ($ website );
2650
+ $ this ->accountManagement ->createAccountWithPasswordHash ($ customer , $ hash );
2651
+ }
2601
2652
}
0 commit comments