public function testReplaceIndividualCodesWithDuplicatePattern(): void
{ $promotionRepository =
$this->
getContainer()->
get('promotion.repository'
);
$salesChannelContext =
$this->
getContainer()->
get(SalesChannelContextFactory::
class) ->
create(Uuid::
randomHex(), TestDefaults::SALES_CHANNEL
);
$id = Uuid::
randomHex();
$duplicatePattern = 'TEST_%d%s_END';
// Create 2 Promotions. The first one has a pattern, which the second will try to use as well later on
$this->
createPromotionWithCustomData(['individualCodePattern' =>
$duplicatePattern],
$promotionRepository,
$salesChannelContext);
$this->
createPromotionWithCustomData(['id' =>
$id],
$promotionRepository,
$salesChannelContext);
$this->
expectExceptionMessage('Code pattern already exists in another promotion. Please provide a different pattern.'
);
$this->codesService->
replaceIndividualCodes($id,
$duplicatePattern, 1,
$salesChannelContext->
getContext());
} public function testAddIndividualCodes(): void
{ $id = Uuid::
randomHex();
$pattern = 'somePattern_%d%d%d';
$data =
[