BillingStateRule example


class BillingStateRuleTest extends TestCase
{
    private BillingStateRule $rule;

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

    public function testName(): void
    {
        static::assertSame('customerBillingState', $this->rule->getName());
    }

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

        

        $ruleId = Uuid::randomHex();
        $this->ruleRepository->create(
            [['id' => $ruleId, 'name' => 'Demo rule', 'priority' => 1]],
            Context::createDefaultContext()
        );

        $id = Uuid::randomHex();
        $this->conditionRepository->create([
            [
                'id' => $id,
                'type' => (new BillingStateRule())->getName(),
                'ruleId' => $ruleId,
                'value' => [
                    'stateIds' => [Uuid::randomHex(), Uuid::randomHex()],
                    'operator' => Rule::OPERATOR_EQ,
                ],
            ],
        ]$this->context);

        static::assertNotNull($this->conditionRepository->search(new Criteria([$id])$this->context)->get($id));
    }
}
Home | Imprint | This part of the site doesn't use cookies.