PromotionCodeOfTypeRule example


                [
                    'id' => $ruleId,
                    'name' => 'LineItemRule',
                    'priority' => 0,
                    'conditions' => [
                        [
                            'type' => (new PromotionValueRule())->getName(),
                            'ruleId' => $ruleId,
                            'children' => [
                                [
                                    'type' => (new PromotionCodeOfTypeRule())->getName(),
                                    'value' => [
                                        'promotionCodeType' => 'test',
                                        'operator' => Rule::OPERATOR_EQ,
                                    ],
                                ],
                            ],
                            'value' => [
                                'amount' => 100,
                                'operator' => Rule::OPERATOR_GTE,
                            ],
                        ],
                    ],
private EntityRepository $conditionRepository;

    private Context $context;

    private PromotionCodeOfTypeRule $rule;

    protected function setUp(): void
    {
        $this->ruleRepository = $this->getContainer()->get('rule.repository');
        $this->conditionRepository = $this->getContainer()->get('rule_condition.repository');
        $this->context = Context::createDefaultContext();
        $this->rule = new PromotionCodeOfTypeRule();
    }

    public function testValidateWithMissingLineItemType(): void
    {
        try {
            $this->conditionRepository->create([
                [
                    'type' => (new PromotionCodeOfTypeRule())->getName(),
                    'ruleId' => Uuid::randomHex(),
                ],
            ]$this->context);
            
Home | Imprint | This part of the site doesn't use cookies.