TagCollection example


    public static function analyzeCases(): iterable
    {
        $tag1 = new TagEntity();
        $tag1->setId('tag-1');
        $tag1->setName('Tag Yellow');

        $tag2 = new TagEntity();
        $tag2->setId('tag-2');
        $tag2->setName('Tag Pink');

        $tags = new TagCollection([$tag1$tag2]);

        yield 'analyze with tokenize' => [
            [
                'maxPurchase' => 20,
                'manufacturerNumber' => 'MANU_001',
                'description' => self::getLongTextDescription(),
                'tags' => $tags,
                'translated' => [
                    'name' => 'Awesome product',
                ],
            ],
            [
$trueCaseSequence = new Sequence();
        $trueCaseSequence->assign(['sequenceId' => 'foobar']);
        $ruleId = Uuid::randomHex();
        $ifSequence = new IfSequence();
        $ifSequence->assign(['ruleId' => $ruleId, 'trueCase' => $trueCaseSequence]);

        $order = new OrderEntity();
        $tagId = Uuid::randomHex();
        $tag = new TagEntity();
        $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();
        


    /** * @dataProvider getMatchValues * * @param array<string>|string|null $givenIdentifier * @param array<string> $ruleIdentifiers */
    public function testRuleMatching(string $operator, bool $isMatching, array $ruleIdentifiers$givenIdentifier): void
    {
        $order = new OrderEntity();
        $tagCollection = new TagCollection();
        $orderTagIds = array_filter(\is_array($givenIdentifier) ? $givenIdentifier : [$givenIdentifier]);
        foreach ($orderTagIds as $orderTagId) {
            $tag = new TagEntity();
            $tag->setId($orderTagId);
            $tagCollection->add($tag);
        }
        $order->setTags($tagCollection);

        $scope = $this->createScope($order);
        $this->rule->assign(['identifiers' => $ruleIdentifiers, 'operator' => $operator]);

        
Home | Imprint | This part of the site doesn't use cookies.