$this->
createPromotion($id, null,
$promotionRepository,
$salesChannelContext);
$this->
createIndividualCode($id,
$codes[0
],
$codeRepository,
$context);
$this->
createIndividualCode($id,
$codes[1
],
$codeRepository,
$context);
$criteria =
(new Criteria([$id])) ->
addAssociation('individualCodes'
);
/** @var PromotionEntity|null $promotion */
$promotion =
$promotionRepository->
search($criteria,
$context)->
get($id);
static::
assertNotNull($promotion);
static::
assertNotNull($promotion->
getIndividualCodes());
static::
assertCount(2,
$promotion->
getIndividualCodes()->
getElements());
$this->codesService->
replaceIndividualCodes($id, 'newPattern_%d%d%s', 10,
$context);
/** @var PromotionEntity $promotion */
$promotion =
$promotionRepository->
search($criteria,
$context)->
first();
static::
assertNotNull($promotion->
getIndividualCodes());
$individualCodes =
$promotion->
getIndividualCodes()->
getElements();
static::
assertCount(10,
$individualCodes);
static::
assertNotContains($codes[0
],
$individualCodes);
static::
assertNotContains($codes[1
],
$individualCodes);
}