SalesChannelRule example


                        ],
                    ],
                ],
            ],
            [
                'id' => $rule2Id,
                'name' => 'second rule',
                'priority' => 42,
                'conditions' => [
                    [
                        'type' => (new SalesChannelRule())->getName(),
                        'value' => [
                            'salesChannelIds' => [
                                $salesChannelId1,
                                $salesChannelId2,
                            ],
                            'operator' => CurrencyRule::OPERATOR_EQ,
                        ],
                    ],
                ],
            ],
        ];

        
class SalesChannelRuleTest extends TestCase
{
    /** * @dataProvider provideTestData * * @param list<string> $salesChannelIds */
    public function testMatchesWithCorrectSalesChannel(string $operator, string $currentSalesChannel, ?array $salesChannelIds, bool $expected): void
    {
        $ruleScope = $this->createRuleScope($currentSalesChannel);

        $salesChannelRule = new SalesChannelRule($operator$salesChannelIds);

        static::assertSame($expected$salesChannelRule->match($ruleScope));
    }

    public static function provideTestData(): \Generator
    {
        yield 'matches with correct sales channel' => [
            Rule::OPERATOR_EQ,
            Uuid::fromStringToHex('test'),
            [Uuid::fromStringToHex('test')],
            true,
        ];
Home | Imprint | This part of the site doesn't use cookies.