9
9
10
10
use Magento \Customer \Api \CustomerRepositoryInterface ;
11
11
use Magento \Customer \Api \Data \CustomerInterface ;
12
+ use Magento \Customer \Model \Context as CustomerContext ;
12
13
use Magento \Customer \Model \Customer ;
13
14
use Magento \Customer \Model \CustomerFactory ;
14
15
use Magento \Customer \Model \ResourceModel \Customer as ResourceCustomer ;
@@ -118,6 +119,9 @@ public function testSetCustomerAsLoggedIn(): void
118
119
{
119
120
$ customer = $ this ->createMock (Customer::class);
120
121
$ customerDto = $ this ->getMockForAbstractClass (CustomerInterface::class);
122
+ $ customer ->expects ($ this ->any ())
123
+ ->method ('getGroupId ' )
124
+ ->willReturn (1 );
121
125
$ customer ->expects ($ this ->any ())
122
126
->method ('getDataModel ' )
123
127
->willReturn ($ customerDto );
@@ -129,6 +133,10 @@ public function testSetCustomerAsLoggedIn(): void
129
133
['customer_data_object_login ' , ['customer ' => $ customerDto ]]
130
134
);
131
135
136
+ $ this ->_httpContextMock ->expects ($ this ->once ())
137
+ ->method ('setValue ' )
138
+ ->with (CustomerContext::CONTEXT_GROUP , self ::callback (fn ($ value ): bool => $ value === '1 ' ), 0 );
139
+
132
140
$ _SESSION = [];
133
141
$ this ->_model ->setCustomerAsLoggedIn ($ customer );
134
142
$ this ->assertSame ($ customer , $ this ->_model ->getCustomer ());
@@ -348,4 +356,17 @@ public function testGetCustomerForRegisteredUser(): void
348
356
349
357
$ this ->assertSame ($ customerMock , $ this ->_model ->getCustomer ());
350
358
}
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
+ }
351
372
}
0 commit comments