TagEntity example

$this->testAnalyze($productData$configFields$expected);

        error_reporting($oldLevel);
    }

    /** * @return iterable<string, array{0:array<string, array<string, string|array<int|string, string|array<int|string>>>|int|string|TagCollection>, 1:array<int, array{field: string, tokenize: bool, ranking: int}>, 2:array<int, int|string>}> */
    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' => [
            [
                
$ruleLoader = $this->createMock(AbstractRuleLoader::class);
        $scopeBuilder = $this->createMock(FlowRuleScopeBuilder::class);

        $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))
        );

        

    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]);

        $match = $this->rule->match($scope);
        if ($isMatching) {
            static::assertTrue($match);
        }
Home | Imprint | This part of the site doesn't use cookies.