$productId1 = Uuid::
randomHex();
$productId2 = Uuid::
randomHex();
$code = 'BF' . Random::
getAlphanumericString(5
);
// prepare promotion
$this->
createTestFixtureProduct($productId1, 65, 19,
$container,
$this->context
);
$this->
createTestFixtureProduct($productId2, 30, 7,
$container,
$this->context
);
// prepare a percentage promotion with 100% OFF
// with a set group of the 2 cheapest items.
$promotionBuilder =
$this->
createPromotionFixtureBuilder($container) ->
addSetGroup('COUNT', 2, 'PRICE_ASC'
) ->
setCode($code) ->
addDiscount(PromotionDiscountEntity::SCOPE_SET, PromotionDiscountEntity::TYPE_PERCENTAGE, 100.0, false, null
);
$cart =
$this->
getCart($promotionBuilder,
$productId1,
$productId2,
$code);
static::
assertEquals(65.0,
$cart->
getPrice()->
getPositionPrice(), 'Position Total Price is wrong'
);
static::
assertEquals(65.0,
$cart->
getPrice()->
getTotalPrice(), 'Total Price is wrong'
);
static::
assertEquals(54.62,
$cart->
getPrice()->
getNetPrice(), 'Net Price is wrong'
);
static::
assertEquals(10.38,
$cart->
getPrice()->
getCalculatedTaxes()->
getAmount(), 'Taxes are wrong'
);
}