99
1010use Magento \Customer \Api \CustomerRepositoryInterface ;
1111use Magento \Customer \Api \Data \CustomerInterface ;
12+ use Magento \Customer \Model \Context as CustomerContext ;
1213use Magento \Customer \Model \Customer ;
1314use Magento \Customer \Model \CustomerFactory ;
1415use Magento \Customer \Model \ResourceModel \Customer as ResourceCustomer ;
@@ -118,6 +119,9 @@ public function testSetCustomerAsLoggedIn(): void
118119 {
119120 $ customer = $ this ->createMock (Customer::class);
120121 $ customerDto = $ this ->getMockForAbstractClass (CustomerInterface::class);
122+ $ customer ->expects ($ this ->any ())
123+ ->method ('getGroupId ' )
124+ ->willReturn (1 );
121125 $ customer ->expects ($ this ->any ())
122126 ->method ('getDataModel ' )
123127 ->willReturn ($ customerDto );
@@ -129,6 +133,10 @@ public function testSetCustomerAsLoggedIn(): void
129133 ['customer_data_object_login ' , ['customer ' => $ customerDto ]]
130134 );
131135
136+ $ this ->_httpContextMock ->expects ($ this ->once ())
137+ ->method ('setValue ' )
138+ ->with (CustomerContext::CONTEXT_GROUP , self ::callback (fn ($ value ): bool => $ value === '1 ' ), 0 );
139+
132140 $ _SESSION = [];
133141 $ this ->_model ->setCustomerAsLoggedIn ($ customer );
134142 $ this ->assertSame ($ customer , $ this ->_model ->getCustomer ());
@@ -348,4 +356,17 @@ public function testGetCustomerForRegisteredUser(): void
348356
349357 $ this ->assertSame ($ customerMock , $ this ->_model ->getCustomer ());
350358 }
359+
360+ public function testSetCustomer (): void
361+ {
362+ $ customer = $ this ->createMock (Customer::class);
363+ $ customer ->expects ($ this ->any ())
364+ ->method ('getGroupId ' )
365+ ->willReturn (1 );
366+ $ this ->_httpContextMock ->expects ($ this ->once ())
367+ ->method ('setValue ' )
368+ ->with (CustomerContext::CONTEXT_GROUP , self ::callback (fn ($ value ): bool => $ value === '1 ' ), 0 );
369+
370+ $ this ->_model ->setCustomer ($ customer );
371+ }
351372}
0 commit comments