AffiliateCodeRule example


class AffiliateCodeRuleTest extends TestCase
{
    use IntegrationTestBehaviour;

    private AffiliateCodeRule $rule;

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

    public function testValidateWithMissingParameters(): void
    {
        try {
            $this->getContainer()->get('rule_condition.repository')->create([
                [
                    'type' => $this->rule->getName(),
                    'ruleId' => Uuid::randomHex(),
                ],
            ], Context::createDefaultContext());
            

class AffiliateCodeRuleTest extends TestCase
{
    public function testGetConstraints(): void
    {
        $constraints = (new AffiliateCodeRule())->getConstraints();

        static::assertArrayHasKey('affiliateCode', $constraints, 'Constraint affiliateCode not found in Rule');
        static::assertEquals($constraints['affiliateCode'][
            new NotBlank(),
            new Type(['type' => 'string']),
        ]);
    }

    public function testName(): void
    {
        $rule = new AffiliateCodeRule();
        
Home | Imprint | This part of the site doesn't use cookies.