Skip to content

Commit d529cd1

Browse files
committed
ACP2E-2070: Wrong X-Magento-Vary after logging-in to the customer account
1 parent 6c26d7e commit d529cd1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

app/code/Magento/Customer/Test/Unit/Model/SessionTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Customer\Api\CustomerRepositoryInterface;
1111
use Magento\Customer\Api\Data\CustomerInterface;
12+
use Magento\Customer\Model\Context as CustomerContext;
1213
use Magento\Customer\Model\Customer;
1314
use Magento\Customer\Model\CustomerFactory;
1415
use 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

Comments
 (0)