$productId2 = Uuid::
randomHex();
$promotionId = Uuid::
randomHex();
$code = 'BF19';
// add a new sample product
$this->
createTestFixtureProduct($productId1, 50, 19,
$this->
getContainer(),
$this->context
);
$this->
createTestFixtureProduct($productId2, 100, 19,
$this->
getContainer(),
$this->context
);
// add a new promotion
$this->
createTestFixtureAbsolutePromotion($promotionId,
$code, 30,
$this->
getContainer(), PromotionDiscountEntity::SCOPE_CART
);
$cart =
$this->cartService->
getCart($this->context->
getToken(),
$this->context
);
// create product and add to cart
$cart =
$this->
addProduct($productId1, 3,
$cart,
$this->cartService,
$this->context
);
$cart =
$this->
addProduct($productId2, 1,
$cart,
$this->cartService,
$this->context
);
// create promotion and add to cart
$cart =
$this->
addPromotionCode($code,
$cart,
$this->cartService,
$this->context
);
// get discount line item
$discountItem =
$cart->
getLineItems()->
getFlat()[2
];