LastNameRule example


class LastNameRuleTest extends TestCase
{
    private LastNameRule $rule;

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

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

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

        
/** * @covers \Shopware\Core\Checkout\Customer\Rule\LastNameRule * * @internal */
#[Package('business-ops')] class LastNameRuleTest extends TestCase
{
    public function testExactMatch(): void
    {
        $rule = (new LastNameRule())->assign(['lastName' => 'shopware']);

        $cart = new Cart('test');

        $customer = new CustomerEntity();
        $customer->setLastName('shopware');

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

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

        
'id' => $idsCollection->get('sequence-3'),
                        'parentId' => $idsCollection->get('sequence-2'),
                        'actionName' => null,
                        'config' => [],
                        'position' => 1,
                        'trueCase' => true,
                        'rule' => [
                            'name' => 'Test customer rule',
                            'priority' => 1,
                            'conditions' => [
                                [
                                    'type' => (new LastNameRule())->getName(),
                                    'value' => [
                                        'lastName' => 'Mustermann',
                                        'operator' => OrderTagRule::OPERATOR_EQ,
                                    ],
                                ],
                            ],
                        ],
                    ],
                    [
                        'id' => $idsCollection->get('sequence-4'),
                        'parentId' => $idsCollection->get('sequence-3'),
                        
Home | Imprint | This part of the site doesn't use cookies.