OrderTagRule example


                        'id' => $idsCollection->get('sequence-1'),
                        'parentId' => null,
                        'actionName' => null,
                        'config' => [],
                        'position' => 1,
                        'rule' => [
                            'name' => 'Test order rule',
                            'priority' => 1,
                            'conditions' => [
                                [
                                    'type' => (new OrderTagRule())->getName(),
                                    'value' => [
                                        'identifiers' => [$idsCollection->get('tag-1')],
                                        'operator' => OrderTagRule::OPERATOR_EQ,
                                    ],
                                ],
                            ],
                        ],
                    ],
                    [
                        'id' => $idsCollection->get('sequence-2'),
                        'parentId' => $idsCollection->get('sequence-1'),
                        

class OrderTagRuleTest extends TestCase
{
    private OrderTagRule $rule;

    protected function setUp(): void
    {
        $this->rule = new OrderTagRule();
    }

    public function testGetName(): void
    {
        static::assertEquals('orderTag', $this->rule->getName());
    }

    public function testRuleConfig(): void
    {
        $expectedConfiguration = [
            'operatorSet' => [
                
$tag->setId($tagId);
        $order->setTags(new TagCollection([$tag]));

        $flow = new StorableFlow('bar', Context::createDefaultContext());
        $flow->setFlowState(new FlowState());
        $flow->setData(OrderAware::ORDER, $order);

        $scopeBuilder->method('build')->willReturn(
            new FlowRuleScope($ordernew Cart('test')$this->createMock(SalesChannelContext::class))
        );

        $rule = new OrderTagRule(Rule::OPERATOR_EQ, [$tagId]);
        $ruleEntity = new RuleEntity();
        $ruleEntity->setId($ruleId);
        $ruleEntity->setPayload($rule);
        $ruleEntity->setAreas([RuleAreas::FLOW_AREA]);
        $ruleLoader->method('load')->willReturn(new RuleCollection([$ruleEntity]));

        $flowExecutor = new FlowExecutor($eventDispatcher$appFlowActionProvider$ruleLoader$scopeBuilder[]);
        $flowExecutor->executeIf($ifSequence$flow);

        static::assertEquals($trueCaseSequence$flow->getFlowState()->currentSequence);
    }
}
Home | Imprint | This part of the site doesn't use cookies.