setCity example

$customer = new CustomerEntity();
        $customer->setId('1');
        $customer->setCustomerNumber('');
        $customer->setFirstName('');
        $customer->setLastName('');

        $address = new CustomerAddressEntity();
        $address->setId('');
        $address->setFirstName('');
        $address->setLastName('');
        $address->setZipcode('');
        $address->setCity('');

        return [
            new ProfileSalutationMissingError($customer),
            new BillingAddressSalutationMissingError($address),
            new ShippingAddressSalutationMissingError($address),
        ];
    }

    /** * @param array<BundleFixture> $bundles */
    
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');
        $customer->setSalutationId($this->getValidSalutationId());
        $customer->setFirstName($faker->firstName);
        $customer->setLastName($faker->lastName);
        $customer->setCustomerNumber('Test');

        

        $address = new Address();
        $address->setId((int) $data['__address_id']);
        $address->setCompany($data['__address_company']);
        $address->setDepartment($data['__address_department']);
        $address->setSalutation($data['__address_salutation']);
        $address->setTitle($data['__address_title']);
        $address->setFirstname($data['__address_firstname']);
        $address->setLastname($data['__address_lastname']);
        $address->setStreet($data['__address_street']);
        $address->setZipcode($data['__address_zipcode']);
        $address->setCity($data['__address_city']);
        $address->setCountryId((int) $data['__address_country_id']);
        $address->setStateId((int) $data['__address_state_id']);
        $address->setVatId($data['__address_ustid']);
        $address->setPhone($data['__address_phone']);
        $address->setAdditionalAddressLine1($data['__address_additional_address_line1']);
        $address->setAdditionalAddressLine2($data['__address_additional_address_line2']);

        if ($address->getCountryId()) {
            $address->setCountry(
                $this->countryHydrator->hydrateCountry($data)
            );
        }
static::assertEquals([new NotBlank()new Type('string')]$constraints['cityName']);
    }

    /** * @dataProvider getMatchValues */
    public function testRuleMatching(string $operator, bool $isMatching, string $billingCity): void
    {
        $cityName = 'kyln123';
        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $customerAddress = new CustomerAddressEntity();
        $customerAddress->setCity($billingCity);

        $customer = new CustomerEntity();
        $customer->setActiveBillingAddress($customerAddress);
        $salesChannelContext->method('getCustomer')->willReturn($customer);
        $scope = new CheckoutRuleScope($salesChannelContext);
        $this->rule->assign(['cityName' => $cityName, 'operator' => $operator]);

        $match = $this->rule->match($scope);
        if ($isMatching) {
            static::assertTrue($match);
        } else {
            
/** * Transfer values from the new address object */
    public function fromAddress(Address $address)
    {
        $this->setCompany((string) $address->getCompany());
        $this->setDepartment((string) $address->getDepartment());
        $this->setSalutation((string) $address->getSalutation());
        $this->setFirstName((string) $address->getFirstname());
        $this->setLastName((string) $address->getLastname());
        $this->setStreet((string) $address->getStreet());
        $this->setCity((string) $address->getCity());
        $this->setZipCode((string) $address->getZipcode());
        $this->setAdditionalAddressLine1((string) $address->getAdditionalAddressLine1());
        $this->setAdditionalAddressLine2((string) $address->getAdditionalAddressLine2());
        $this->setCountry($address->getCountry());
        $this->setPhone((string) $address->getPhone());
        $this->setVatId((string) $address->getVatId());
        $this->setTitle($address->getTitle());

        if ($address->getState()) {
            $this->setState($address->getState());
        } else {
            
static::assertEquals(new Type('string')$cityName[1]);
    }

    /** * @dataProvider getMatchValues */
    public function testRuleMatching(string $operator, bool $isMatching, string $billingCity): void
    {
        $cityName = 'kyln123';
        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $customerAddress = new CustomerAddressEntity();
        $customerAddress->setCity($billingCity);

        $shippingLocation = new ShippingLocation(new CountryEntity(), null, $customerAddress);
        $salesChannelContext->method('getShippingLocation')->willReturn($shippingLocation);
        $scope = new CheckoutRuleScope($salesChannelContext);
        $this->rule->assign(['cityName' => $cityName, 'operator' => $operator]);

        $match = $this->rule->match($scope);
        if ($isMatching) {
            static::assertTrue($match);
        } else {
            static::assertFalse($match);
        }
/** * Transfer values from the new address object */
    public function fromAddress(Address $address)
    {
        $this->setCompany((string) $address->getCompany());
        $this->setDepartment((string) $address->getDepartment());
        $this->setSalutation((string) $address->getSalutation());
        $this->setFirstName((string) $address->getFirstname());
        $this->setLastName((string) $address->getLastname());
        $this->setStreet((string) $address->getStreet());
        $this->setCity((string) $address->getCity());
        $this->setZipCode((string) $address->getZipcode());
        $this->setAdditionalAddressLine1((string) $address->getAdditionalAddressLine1());
        $this->setAdditionalAddressLine2((string) $address->getAdditionalAddressLine2());
        $this->setCountry($address->getCountry());
        $this->setPhone($address->getPhone());
        $this->setTitle($address->getTitle());
        if ($address->getState()) {
            $this->setState($address->getState());
        } else {
            $this->setState(null);
        }

        


    private function getCustomerAddress(): CustomerAddressEntity
    {
        $address = new CustomerAddressEntity();
        $address->setId('billing-address-id');
        $address->setSalutationId('billing-address-salutation-id');
        $address->setFirstName('billing-address-first-name');
        $address->setLastName('billing-address-last-name');
        $address->setStreet('billing-address-street');
        $address->setZipcode('billing-address-zipcode');
        $address->setCity('billing-address-city');
        $address->setCountryId('billing-address-country-id');

        return $address;
    }

    private function getOrderCustomer(): OrderCustomerEntity
    {
        $customer = new OrderCustomerEntity();
        $customer->setId('order-customer-id');
        $customer->setCustomerId('customer-id');
        $customer->setEmail('order-customer-email');
        
Home | Imprint | This part of the site doesn't use cookies.