setSalutationId example

static::assertInstanceOf(CartException::class$exception);
        static::assertStringContainsString('Line item "test" incomplete. Property "label" missing.', $exception->getMessage());
    }

    private function getCustomer(): CustomerEntity
    {
        $faker = Factory::create();

        $billingAddress = new CustomerAddressEntity();
        $billingAddress->setId('SWAG-ADDRESS-ID-1');
        $billingAddress->setSalutationId($this->getValidSalutationId());
        $billingAddress->setFirstName($faker->firstName);
        $billingAddress->setLastName($faker->lastName);
        $billingAddress->setStreet($faker->streetAddress);
        $billingAddress->setZipcode($faker->postcode);
        $billingAddress->setCity($faker->city);
        $billingAddress->setCountryId('SWAG-AREA-COUNTRY-ID-1');

        $customer = new CustomerEntity();
        $customer->setId('SWAG-CUSTOMER-ID-1');
        $customer->setDefaultBillingAddress($billingAddress);
        $customer->setEmail('test@example.com');
        
->method('upsert')
            ->with(static::callback(function Darray $data) use ($salutationId) {
                static::assertCount(1, $data);
                static::assertIsArray($data[0]);
                static::assertSame($data[0]['salutationId']$salutationId);

                return true;
            }));

        $address = new CustomerAddressEntity();
        $address->setId(Uuid::randomHex());
        $address->setSalutationId($salutationId);

        $addressRepository->expects(static::once())->method('search')->willReturn(
            new EntitySearchResult(
                'customer_address',
                1,
                new EntityCollection([$address]),
                null,
                new Criteria(),
                Context::createDefaultContext()
            )
        );

        
$orderAddressRepository,
            $initialStateIdLoader,
            $lineItemDownloadLoader
        );
    }

    private function getCustomer(bool $withoutBillingAddress): CustomerEntity
    {
        $customer = new CustomerEntity();
        $customer->setId('customer-id');
        $customer->setEmail('customer-email');
        $customer->setSalutationId('customer-salutation-id');
        $customer->setFirstName('customer-first-name');
        $customer->setLastName('customer-last-name');
        $customer->setCustomerNumber('customer-number');
        $customer->setGroupId('customer-group-id');

        if (!$withoutBillingAddress) {
            $customer->setDefaultBillingAddress($this->getCustomerAddress());
        }

        return $customer;
    }

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