ArrayOfUuid example

$operators = [
            Rule::OPERATOR_EQ,
            Rule::OPERATOR_NEQ,
            Rule::OPERATOR_EMPTY,
        ];

        $constraints = $this->rule->getConstraints();

        static::assertArrayHasKey('identifiers', $constraints, 'identifiers constraint not found');
        static::assertArrayHasKey('operator', $constraints, 'operator constraints not found');

        static::assertEquals([new NotBlank()new ArrayOfUuid()]$constraints['identifiers']);
        static::assertEquals([new NotBlank()new Choice($operators)]$constraints['operator']);
    }

    /** * @dataProvider getMatchValues * * @param array<string>|string|null $givenIdentifier * @param array<string> $ruleIdentifiers */
    public function testRuleMatching(string $operator, bool $isMatching, array $ruleIdentifiers$givenIdentifier): void
    {
        
$ruleConstraints = $this->rule->getConstraints();

        static::assertArrayHasKey('operator', $ruleConstraints, 'Constraint operator not found in Rule');
        $operators = $ruleConstraints['operator'];
        static::assertEquals(new NotBlank()$operators[0]);
        static::assertEquals(new Choice($expectedOperators)$operators[1]);

        $this->rule->assign(['operator' => Rule::OPERATOR_EQ]);
        static::assertArrayHasKey('languageIds', $ruleConstraints, 'Constraint languageIds not found in Rule');
        $languageIds = $ruleConstraints['languageIds'];
        static::assertEquals(new NotBlank()$languageIds[0]);
        static::assertEquals(new ArrayOfUuid()$languageIds[1]);
    }

    /** * @dataProvider getMatchValues */
    public function testRuleMatching(string $operator, bool $isMatching, string $languageId): void
    {
        $languageIds = ['kyln123', 'kyln456'];
        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $context = new Context(new SystemSource()[], Defaults::CURRENCY, [$languageId]);

        
$ruleConstraints = $this->rule->getConstraints();

        static::assertArrayHasKey('operator', $ruleConstraints, 'Constraint operator not found in Rule');
        $operators = $ruleConstraints['operator'];
        static::assertEquals(new NotBlank()$operators[0]);
        static::assertEquals(new Choice($expectedOperators)$operators[1]);

        $this->rule->assign(['operator' => Rule::OPERATOR_EQ]);
        static::assertArrayHasKey('countryIds', $ruleConstraints, 'Constraint countryIds not found in Rule');
        $countryIds = $ruleConstraints['countryIds'];
        static::assertEquals(new NotBlank()$countryIds[0]);
        static::assertEquals(new ArrayOfUuid()$countryIds[1]);
    }

    /** * @dataProvider getMatchValues */
    public function testRuleMatching(string $operator, bool $isMatching, string $countryId): void
    {
        $countryIds = ['kyln123', 'kyln456'];
        $salesChannelContext = $this->createMock(SalesChannelContext::class);

        $country = new CountryEntity();
        
$ruleConstraints = $this->rule->getConstraints();

        static::assertArrayHasKey('operator', $ruleConstraints, 'Constraint operator not found in Rule');
        $operators = $ruleConstraints['operator'];
        static::assertEquals(new NotBlank()$operators[0]);
        static::assertEquals(new Choice($expectedOperators)$operators[1]);

        $this->rule->assign(['operator' => Rule::OPERATOR_EQ]);
        static::assertArrayHasKey('streamIds', $ruleConstraints, 'Constraint streamIds not found in Rule');
        $streamIds = $ruleConstraints['streamIds'];
        static::assertEquals(new NotBlank()$streamIds[0]);
        static::assertEquals(new ArrayOfUuid()$streamIds[1]);
    }

    /** * @param array<string> $streamIds */
    private function createLineItemWithProductStreams(array $streamIds): LineItem
    {
        return $this->createLineItem()->setPayloadValue('streamIds', $streamIds);
    }
}
static::assertSame('customerBillingState', $this->rule->getName());
    }

    public function testConstraints(): void
    {
        $constraints = $this->rule->getConstraints();

        static::assertArrayHasKey('operator', $constraints, 'Constraint operator not found in Rule');
        static::assertArrayHasKey('stateIds', $constraints, 'Constraint stateIds not found in Rule');

        static::assertEquals([new NotBlank()new Choice([Rule::OPERATOR_EQ, Rule::OPERATOR_NEQ, Rule::OPERATOR_EMPTY])]$constraints['operator']);
        static::assertEquals([new NotBlank()new ArrayOfUuid()]$constraints['stateIds']);
    }

    /** * @dataProvider getMatchValues */
    public function testRuleMatching(string $operator, bool $isMatching, string $stateId): void
    {
        $countryIds = ['kyln123', 'kyln456'];
        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $customerAddress = new CustomerAddressEntity();
        $customerAddress->setCountryStateId($stateId);
        
$operators = [
            Rule::OPERATOR_EQ,
            Rule::OPERATOR_NEQ,
            Rule::OPERATOR_EMPTY,
        ];

        $constraints = $this->rule->getConstraints();

        static::assertArrayHasKey('identifiers', $constraints, 'identifiers constraint not found');
        static::assertArrayHasKey('operator', $constraints, 'operator constraints not found');

        static::assertEquals(new ArrayOfUuid()$constraints['identifiers'][1]);
        static::assertEquals(new Choice($operators)$constraints['operator'][1]);
    }

    /** * @dataProvider getMatchValues * * @param string|list<string>|null $givenIdentifier * @param array<string> $ruleIdentifiers */
    public function testRuleMatching(string $operator, bool $isMatching, array $ruleIdentifiers, array|string|null $givenIdentifier, bool $noCustomer = false): void
    {
        
continue;
            }

            if ($field instanceof IntField) {
                $constraints[$field->getName()][] = new Type('int');

                continue;
            }

            if ($field instanceof MultiEntitySelectField) {
                $constraints[$field->getName()][] = new ArrayOfUuid();

                continue;
            }

            if ($field instanceof SingleEntitySelectField || $field instanceof MediaSelectionField) {
                $constraints[$field->getName()][] = new Uuid();

                continue;
            }

            if ($field instanceof MultiSelectField) {
                
$constraints = [
            'operator' => [
                new NotBlank(),
                new Choice([self::OPERATOR_EQ, self::OPERATOR_NEQ, self::OPERATOR_EMPTY]),
            ],
        ];

        if ($this->operator === self::OPERATOR_EMPTY) {
            return $constraints;
        }

        $constraints['stateIds'] = [new NotBlank()new ArrayOfUuid()];

        return $constraints;
    }

    public function getConfig(): RuleConfig
    {
        return (new RuleConfig())
            ->operatorSet(RuleConfig::OPERATOR_SET_STRING, true, true)
            ->entitySelectField('stateIds', CountryStateDefinition::ENTITY_NAME, true);
    }
}
$ruleConstraints = $this->rule->getConstraints();

        static::assertArrayHasKey('operator', $ruleConstraints, 'Constraint operator not found in Rule');
        $operators = $ruleConstraints['operator'];
        static::assertEquals(new NotBlank()$operators[0]);
        static::assertEquals(new Choice($expectedOperators)$operators[1]);

        $this->rule->assign(['operator' => Rule::OPERATOR_EQ]);
        static::assertArrayHasKey('countryIds', $ruleConstraints, 'Constraint countryIds not found in Rule');
        $countryIds = $ruleConstraints['countryIds'];
        static::assertEquals(new NotBlank()$countryIds[0]);
        static::assertEquals(new ArrayOfUuid()$countryIds[1]);
    }

    public function testRuleNotMatchingWithoutCountry(): void
    {
        $this->rule->assign(['countryIds' => ['foo'], 'operator' => Rule::OPERATOR_EQ]);
        $salesChannelContext = $this->createMock(SalesChannelContext::class);

        static::assertFalse($this->rule->match(new CheckoutRuleScope($salesChannelContext)));

        $customer = new CustomerEntity();
        $salesChannelContext->method('getCustomer')->willReturn($customer);

        
$constraints = [
            'operator' => [
                new NotBlank(),
                new Choice([self::OPERATOR_EQ, self::OPERATOR_NEQ, self::OPERATOR_EMPTY]),
            ],
        ];

        if ($this->operator === self::OPERATOR_EMPTY) {
            return $constraints;
        }

        $constraints['stateIds'] = [new NotBlank()new ArrayOfUuid()];

        return $constraints;
    }

    public function getConfig(): RuleConfig
    {
        return (new RuleConfig())
            ->operatorSet(RuleConfig::OPERATOR_SET_STRING, true, true)
            ->entitySelectField('stateIds', CountryStateDefinition::ENTITY_NAME, true);
    }
}
$ruleConstraints = $this->rule->getConstraints();

        static::assertArrayHasKey('operator', $ruleConstraints, 'Constraint operator not found in Rule');
        $operators = $ruleConstraints['operator'];
        static::assertEquals(new NotBlank()$operators[0]);
        static::assertEquals(new Choice($expectedOperators)$operators[1]);

        $this->rule->assign(['operator' => Rule::OPERATOR_EQ]);
        static::assertArrayHasKey('categoryIds', $ruleConstraints, 'Constraint categoryIds not found in Rule');
        $categoryIds = $ruleConstraints['categoryIds'];
        static::assertEquals(new NotBlank()$categoryIds[0]);
        static::assertEquals(new ArrayOfUuid()$categoryIds[1]);
    }

    /** * @param array<string> $categoryIds */
    private function createLineItemWithCategories(array $categoryIds): LineItem
    {
        return $this->createLineItem()->setPayloadValue('categoryIds', $categoryIds);
    }
}
$ruleConstraints = $this->rule->getConstraints();

        static::assertArrayHasKey('operator', $ruleConstraints, 'Constraint operator not found in Rule');
        $operators = $ruleConstraints['operator'];
        static::assertEquals(new NotBlank()$operators[0]);
        static::assertEquals(new Choice($expectedOperators)$operators[1]);

        $this->rule->assign(['operator' => Rule::OPERATOR_EQ]);
        static::assertArrayHasKey('identifiers', $ruleConstraints, 'Constraint identifiers not found in Rule');
        $identifiers = $ruleConstraints['identifiers'];
        static::assertEquals(new NotBlank()$identifiers[0]);
        static::assertEquals(new ArrayOfUuid()$identifiers[1]);
    }

    /** * @dataProvider getMatchValues */
    public function testRuleMatching(string $operator, bool $isMatching, ?string $tag, bool $withItemWithoutPayload = true): void
    {
        $identifiers = ['kyln123', 'kyln456'];
        if ($tag !== null) {
            $lineItems = [
                $this->createLineItem()->replacePayload(['tagIds' => [$tag]]),
            ];
$operators = [
            Rule::OPERATOR_EQ,
            Rule::OPERATOR_NEQ,
            Rule::OPERATOR_EMPTY,
        ];

        $constraints = $this->rule->getConstraints();

        static::assertArrayHasKey('documentIds', $constraints, 'documentIds constraint not found');
        static::assertArrayHasKey('operator', $constraints, 'operator constraints not found');

        static::assertEquals([new NotBlank()new ArrayOfUuid()]$constraints['documentIds']);
        static::assertEquals([new NotBlank()new Choice($operators)]$constraints['operator']);
    }

    /** * @dataProvider getMatchingValues * * @param list<string> $selectedDocumentIds */
    public function testOrderDocumentTypeRuleMatching(bool $expected, string|null $documentId, array $selectedDocumentIds, string $operator): void
    {
        $order = new OrderEntity();
        
$ruleConstraints = $this->rule->getConstraints();

        static::assertArrayHasKey('operator', $ruleConstraints, 'Constraint operator not found in Rule');
        $operators = $ruleConstraints['operator'];
        static::assertEquals(new NotBlank()$operators[0]);
        static::assertEquals(new Choice($expectedOperators)$operators[1]);

        $this->rule->assign(['operator' => Rule::OPERATOR_EQ]);
        static::assertArrayHasKey('stateIds', $ruleConstraints, 'Constraint stateIds not found in Rule');
        $stateIds = $ruleConstraints['stateIds'];
        static::assertEquals(new NotBlank()$stateIds[0]);
        static::assertEquals(new ArrayOfUuid()$stateIds[1]);
    }

    /** * @dataProvider getMatchValues */
    public function testRuleMatching(string $operator, bool $isMatching, string $stateId, bool $stateExists = true): void
    {
        $countryIds = ['kyln123', 'kyln456'];
        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $state = new CountryStateEntity();
        $state->setId($stateId);
        
$constraint[] = new Type('bool');

        return $constraint;
    }

    /** * @return array<int, Constraint> */
    public static function uuids(): array
    {
        return [new NotBlank()new ArrayOfUuid()];
    }

    /** * @return array<int, Constraint> */
    public static function datetime(): array
    {
        return [new NotBlank()new Type('string')];
    }

    /** * @param array<int, string> $choices * * @return array<int, Constraint> */
Home | Imprint | This part of the site doesn't use cookies.