IsNewCustomerRule example

$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 IsNewCustomerRule())->getName(),
                'ruleId' => $ruleId,
                'value' => [
                    'isNew' => true,
                ],
            ],
        ]$this->context);

        static::assertNotNull($this->conditionRepository->search(new Criteria([$id])$this->context)->get($id));
    }
}

#[Package('business-ops')] class IsNewCustomerRuleTest extends TestCase
{
    public function testIsNewCustomer(): void
    {
        Feature::skipTestIfActive('v6.6.0.0', $this);

        $rule = new IsNewCustomerRule();

        $cart = new Cart('test');

        $customer = new CustomerEntity();
        $customer->setFirstLogin(new \DateTime());

        $context = $this->createMock(SalesChannelContext::class);

        $context
            ->method('getCustomer')
            ->willReturn($customer);

        
Home | Imprint | This part of the site doesn't use cookies.