$salesChannelContext =
$this->
createDefaultSalesChannelContext();
$this->
createTestFixtureFixedDiscountPromotion(Uuid::
randomHex(), 40, PromotionDiscountEntity::SCOPE_CART, null,
$this->
getContainer(),
$salesChannelContext);
$browser =
$this->
createCart(TestDefaults::SALES_CHANNEL,
$salesChannelContext->
getToken());
$productId = Uuid::
randomHex();
$this->
createTestFixtureProduct($productId, 119, 19,
$this->
getContainer(),
$salesChannelContext);
$this->
addProduct($browser, TestDefaults::SALES_CHANNEL,
$productId);
// Add promotion code into cart
$promotionCode = Random::
getAlphanumericString(5
);
$this->
createTestFixtureAbsolutePromotion(Uuid::
randomHex(),
$promotionCode, 100,
$this->
getContainer());
$this->
addPromotionCodeByAPI($browser, TestDefaults::SALES_CHANNEL,
$promotionCode);
// Check there are automatic promotion and promotion code in cart
$cart =
$this->
getCart($browser, TestDefaults::SALES_CHANNEL
);
static::
assertCount(3,
$cart['lineItems'
]);
static::
assertSame('product',
$cart['lineItems'
][0
]['type'
]);
static::
assertSame('promotion',
$cart['lineItems'
][1
]['type'
]);
static::
assertSame('promotion',
$cart['lineItems'
][2
]['type'
]);
static::
assertSame($promotionCode,
$cart['lineItems'
][2
]['referencedId'
]);
// Call to disable automatic promotion