private SalesChannelContextPersister
$contextPersister;
private SalesChannelContext
$salesChannelContext;
private ApiOrderCartService
$adminOrderCartService;
protected function setUp(): void
{ $this->connection =
$this->
getContainer()->
get(Connection::
class);
$eventDispatcher =
new EventDispatcher();
$this->contextPersister =
new SalesChannelContextPersister($this->connection,
$eventDispatcher,
$this->
getContainer()->
get(CartPersister::
class));
$this->salesChannelContext =
$this->
getContainer()->
get(SalesChannelContextFactory::
class) ->
create(Uuid::
randomHex(), TestDefaults::SALES_CHANNEL
);
$this->adminOrderCartService =
$this->
getContainer()->
get(ApiOrderCartService::
class);
} public function testAddPermission(): void
{ $this->adminOrderCartService->
addPermission($this->salesChannelContext->
getToken(), PromotionCollector::SKIP_AUTOMATIC_PROMOTIONS,
$this->salesChannelContext->
getSalesChannelId());
$payload =
$this->contextPersister->
load($this->salesChannelContext->
getToken(),
$this->salesChannelContext->
getSalesChannelId());
static::
assertArrayHasKey(PromotionCollector::SKIP_AUTOMATIC_PROMOTIONS,
$payload[SalesChannelContextService::PERMISSIONS
]);
static::
assertTrue($payload[SalesChannelContextService::PERMISSIONS
][PromotionCollector::SKIP_AUTOMATIC_PROMOTIONS
]);
}