setSetGroupRules example

$rule = new RuleEntity();
        $rule->setId('R1');
        $rule->setPayload((new LineItemUnitPriceRule())->assign(['amount' => 10, 'operator' => '=']));

        $ruleCollection = new RuleCollection([$rule]);

        $group = new PromotionSetGroupEntity();
        $group->setId(Uuid::randomBytes());
        $group->setPackagerKey('COUNT');
        $group->setValue(2);
        $group->setSorterKey('PRICE_ASC');
        $group->setSetGroupRules($ruleCollection);

        $this->promotion->setSetgroups(new PromotionSetGroupCollection([$group]));

        $builder = new PromotionItemBuilder();

        $item = $builder->buildDiscountLineItem('', $this->promotion, $discount, Defaults::CURRENCY, $currencyFactor);

        $expected = [
            'promotionId' => 'PR-1',
            'discountType' => 'percentage',
            'value' => '0',
            
/** * @param RuleEntity[] $rules */
    private function createSetGroup(string $packagerKey, float $value, string $sorterKey, array $rules): PromotionSetGroupEntity
    {
        $group = new PromotionSetGroupEntity();
        $group->setId(Uuid::randomBytes());

        $group->setPackagerKey($packagerKey);
        $group->setValue($value);
        $group->setSorterKey($sorterKey);
        $group->setSetGroupRules(new RuleCollection($rules));

        return $group;
    }

    private function createSetGroupWithRuleFixture(string $groupId, string $packagerKey, float $value, string $sorterKey, string $promotionId, string $ruleId, ContainerInterface $container): string
    {
        $context = $container->get(SalesChannelContextFactory::class)->create(Uuid::randomHex(), TestDefaults::SALES_CHANNEL);

        $repository = $container->get('promotion_setgroup.repository');

        $data = [
            

    public function testPropertyPackagerKey(): void
    {
        $group = new PromotionSetGroupEntity();
        $group->setPackagerKey(self::KEY_PACKAGER_COUNT);
        $group->setValue(9);
        $group->setSorterKey('');
        $group->setSetGroupRules(new RuleCollection());

        static::assertEquals(self::KEY_PACKAGER_COUNT, $group->getPackagerKey());
    }

    /** * This test verifies that our assignment and * getter work correctly for the property. * * @group promotions */
    public function testPropertyValue(): void
    {
Home | Imprint | This part of the site doesn't use cookies.