Exemplo n.º 1
0
 /**
  * @magentoDataFixture Magento/Customer/_files/customer.php
  * @magentoDataFixture Magento/Customer/_files/customer_address.php
  * @magentoDataFixture Magento/Checkout/_files/quote_with_product_and_payment.php
  */
 public function testGetAddress()
 {
     $addressFromFixture = $this->_addressService->getAddress(self::FIXTURE_ADDRESS_ID);
     $address = $this->_block->getAddress();
     $this->assertEquals($addressFromFixture->getFirstname(), $address->getFirstname());
     $this->assertEquals($addressFromFixture->getLastname(), $address->getLastname());
     $this->assertEquals($addressFromFixture->getCustomerId(), $address->getCustomerId());
 }
Exemplo n.º 2
0
 public function testGetDefaultRateRequest()
 {
     $customerDataSet = $this->_customerAccountService->getCustomer(self::FIXTURE_CUSTOMER_ID);
     $address = $this->_addressService->getAddress(self::FIXTURE_ADDRESS_ID);
     $rateRequest = $this->_model->getRateRequest(null, null, null, null, $customerDataSet->getId());
     $this->assertNotNull($rateRequest);
     $this->assertEquals($address->getCountryId(), $rateRequest->getCountryId());
     $this->assertEquals($address->getRegion()->getRegionId(), $rateRequest->getRegionId());
     $this->assertEquals($address->getPostcode(), $rateRequest->getPostcode());
     $customerTaxClassId = $this->_groupService->getGroup($customerDataSet->getGroupId())->getTaxClassId();
     $this->assertEquals($customerTaxClassId, $rateRequest->getCustomerClassId());
 }
Exemplo n.º 3
0
 /**
  * Assign customer model to quote with billing and shipping address change
  *
  * @param  CustomerDataObject|\Magento\Customer\Model\Customer $customer
  * @param  Address $billingAddress Quote billing address
  * @param  Address $shippingAddress Quote shipping address
  * @return $this
  */
 public function assignCustomerWithAddressChange($customer, Address $billingAddress = null, Address $shippingAddress = null)
 {
     /* @TODO: refactor this once all the usages of assignCustomerWithAddressChange are refactored MAGETWO-19930 */
     if ($customer instanceof \Magento\Customer\Model\Customer) {
         $customer = $this->_converter->createCustomerFromModel($customer);
     }
     /** @var CustomerDataObject $customer */
     if ($customer->getId()) {
         $this->setCustomerData($customer);
         if (null !== $billingAddress) {
             $this->setBillingAddress($billingAddress);
         } else {
             try {
                 $defaultBillingAddress = $this->_addressService->getDefaultBillingAddress($customer->getId());
             } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
             }
             if (isset($defaultBillingAddress)) {
                 /** @var \Magento\Sales\Model\Quote\Address $billingAddress */
                 $billingAddress = $this->_quoteAddressFactory->create();
                 $billingAddress->importCustomerAddressData($defaultBillingAddress);
                 $this->setBillingAddress($billingAddress);
             }
         }
         if (null === $shippingAddress) {
             try {
                 $defaultShippingAddress = $this->_addressService->getDefaultShippingAddress($customer->getId());
             } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
             }
             if (isset($defaultShippingAddress)) {
                 /** @var \Magento\Sales\Model\Quote\Address $shippingAddress */
                 $shippingAddress = $this->_quoteAddressFactory->create();
                 $shippingAddress->importCustomerAddressData($defaultShippingAddress);
             } else {
                 $shippingAddress = $this->_quoteAddressFactory->create();
             }
         }
         $this->setShippingAddress($shippingAddress);
     }
     return $this;
 }
Exemplo n.º 4
0
 /**
  * test getDefaultShippingAddress
  */
 public function testGetDefaultShippingAddress()
 {
     $this->currentCustomerMock->expects($this->once())->method('getCustomerId')->will($this->returnValue($this->customerCurrentId));
     $this->customerAddressServiceMock->expects($this->once())->method('getDefaultShippingAddress')->will($this->returnValue($this->customerAddressDataMock));
     $this->assertEquals($this->customerAddressDataMock, $this->currentCustomerAddress->getDefaultShippingAddress());
 }