addressBook example

$request->attributes->set(RequestTransformer::STOREFRONT_URL, 'shopware.test');
        $request->setSession($this->getSession());

        $this->getContainer()->get('request_stack')->push($request);

        $customer1 = $context->getCustomer();
        static::assertNotNull($customer1);
        $oldBillingAddressId = $customer1->getDefaultBillingAddressId();
        $oldShippingAddressId = $customer1->getDefaultShippingAddressId();

        $dataBag = $this->getDataBag('billing');
        $controller->addressBook($request$dataBag$context$customer1);
        $customer = $this->customerRepository->search(new Criteria([$customerId])$context->getContext())->first();
        static::assertInstanceOf(CustomerEntity::class$customer);

        static::assertNotSame($oldBillingAddressId$customer->getDefaultBillingAddressId());
        static::assertSame($oldShippingAddressId$customer->getDefaultShippingAddressId());
    }

    public function testCreateShippingAddressIsNewSelectedAddress(): void
    {
        [$customerId] = $this->createCustomers();

        


    public function testAddressBook(): void
    {
        $context = Generator::createSalesChannelContext();
        $request = new Request();
        $dataBag = new RequestDataBag();

        $customer = new CustomerEntity();
        $customer->setId(Uuid::randomHex());

        $response = $this->controller->addressBook($request$dataBag$context$customer);
        static::assertEquals(Response::HTTP_OK, $response->getStatusCode());

        $renderParams = $this->controller->renderStorefrontParameters;

        static::assertArrayHasKey('messages', $renderParams);
        static::assertCount(0, $renderParams['messages']);
        static::assertArrayHasKey('page', $renderParams);
        static::assertArrayNotHasKey('formViolations', $renderParams);
        static::assertArrayNotHasKey('postedData', $renderParams);
    }

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