$customerId =
$this->
createCustomer($salesChannelContext, 'info@example.com'
);
$browser =
$this->
createCart($salesChannel['id'
]);
$browser->
request('PATCH',
$this->
getRootProxyUrl('/switch-customer'
),
[ 'salesChannelId' =>
$salesChannel['id'
],
'customerId' =>
$customerId,
]);
$response =
$this->
getBrowser()->
getResponse();
$contextTokenHeaderName =
$this->
getContextTokenHeaderName();
static::
assertTrue($response->headers->
has(PlatformRequest::HEADER_CONTEXT_TOKEN
));
static::
assertEquals($browser->
getServerParameter($contextTokenHeaderName),
$response->headers->
get(PlatformRequest::HEADER_CONTEXT_TOKEN
));
static::
assertIsString($salesChannel['id'
]);
// assert customer is updated in database
$payload =
$this->contextPersister->
load($response->headers->
get(PlatformRequest::HEADER_CONTEXT_TOKEN, ''
),
$salesChannel['id'
]);
static::
assertArrayHasKey('customerId',
$payload);
static::
assertEquals($customerId,
$payload['customerId'
]);
} public function testSwitchCustomerWithPermissions(): void
{