public function testGetQuoteShippingAddressesItems()
 {
     $quoteItem = $this->getMock('Magento\\Quote\\Model\\Quote\\Address\\Item', [], [], '', false);
     $this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($this->quoteMock);
     $this->quoteMock->expects($this->once())->method('getShippingAddressesItems')->willReturn($quoteItem);
     $this->model->getQuoteShippingAddressesItems();
 }
Esempio n. 2
0
 /**
  * Retrieve billing address
  *
  * @return \Magento\Sales\Model\Quote\Address
  */
 public function getAddress()
 {
     $address = $this->getData('address');
     if (is_null($address)) {
         $address = $this->_multishipping->getQuote()->getBillingAddress();
         $this->setData('address', $address);
     }
     return $address;
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function setShippingMethods($methods)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setShippingMethods');
     if (!$pluginInfo) {
         return parent::setShippingMethods($methods);
     } else {
         return $this->___callPlugins('setShippingMethods', func_get_args(), $pluginInfo);
     }
 }
 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Please check billing address information.
  */
 public function testSetQuoteCustomerBillingAddressForAddressLeak()
 {
     $addressId = 43;
     $customerAddressId = 42;
     $customerAddressMock = $this->getMock('\\Magento\\Customer\\Model\\Data\\Address', [], [], '', false);
     $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId);
     $customerAddresses = [$customerAddressMock];
     $this->customerMock->expects($this->once())->method('getAddresses')->willReturn($customerAddresses);
     $this->assertEquals($this->model, $this->model->setQuoteCustomerBillingAddress($addressId));
 }
Esempio n. 5
0
 /**
  * Test case when customer has no addresses.
  *
  * @param string $addressType
  * @magentoDataFixture Magento/Customer/_files/customer.php
  * @magentoAppIsolation enabled
  * @dataProvider getCustomerDefaultAddressDataProvider
  */
 public function testGetCustomerDefaultAddressCustomerWithoutAddresses($addressType)
 {
     /**
      * Preconditions:
      * - customer has no addresses
      * - current customer is set to customer session
      */
     $fixtureCustomerId = 1;
     /** @var \Magento\Customer\Model\Customer $customer */
     $customer = Bootstrap::getObjectManager()->create('Magento\\Customer\\Model\\Customer')->load($fixtureCustomerId);
     $customer->setDefaultShipping(null)->setDefaultBilling(null)->save();
     /** @var \Magento\Customer\Model\Session $customerSession */
     $customerSession = Bootstrap::getObjectManager()->get('Magento\\Customer\\Model\\Session');
     $customerSession->setCustomer($customer);
     /** Execute SUT */
     if ($addressType == self::ADDRESS_TYPE_SHIPPING) {
         $address = $this->_multishippingCheckout->getCustomerDefaultShippingAddress();
     } else {
         // billing
         $address = $this->_multishippingCheckout->getCustomerDefaultBillingAddress();
     }
     $this->assertNull($address, "When customer has no addresses, null is expected.");
 }
 public function testSetShippingMethods()
 {
     $methodsArray = [1 => 'flatrate_flatrate', 2 => 'tablerate_bestway'];
     $addressId = 1;
     $addressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, ['getId', 'setShippingMethod'], [], '', false);
     $extensionAttributesMock = $this->getMock(\Magento\Quote\Api\Data\CartExtension::class, ['setShippingAssignments'], [], '', false);
     $shippingAssignmentMock = $this->getMock(\Magento\Quote\Model\ShippingAssignment::class, ['getShipping', 'setShipping'], [], '', false);
     $shippingMock = $this->getMock(\Magento\Quote\Model\Shipping::class, ['setMethod'], [], '', false);
     $addressMock->expects($this->once())->method('getId')->willReturn($addressId);
     $this->quoteMock->expects($this->once())->method('getAllShippingAddresses')->willReturn([$addressMock]);
     $addressMock->expects($this->once())->method('setShippingMethod')->with($methodsArray[$addressId]);
     //mock for prepareShippingAssignment
     $this->quoteMock->expects($this->once())->method('getExtensionAttributes')->willReturn($extensionAttributesMock);
     $this->shippingAssignmentProcessorMock->expects($this->once())->method('create')->with($this->quoteMock)->willReturn($shippingAssignmentMock);
     $shippingAssignmentMock->expects($this->once())->method('getShipping')->willReturn($shippingMock);
     $shippingMock->expects($this->once())->method('setMethod')->with(null)->willReturnSelf();
     $shippingAssignmentMock->expects($this->once())->method('setShipping')->with($shippingMock);
     $extensionAttributesMock->expects($this->once())->method('setShippingAssignments')->with([$shippingAssignmentMock])->willReturnSelf();
     $this->quoteMock->expects($this->once())->method('setExtensionAttributes')->with($extensionAttributesMock);
     //save mock
     $this->quoteMock->expects($this->once())->method('collectTotals')->willReturnSelf();
     $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock);
     $this->model->setShippingMethods($methodsArray);
 }
Esempio n. 7
0
 /**
  * Retrieve payment info model
  *
  * @return \Magento\Payment\Model\Info
  */
 public function getPaymentInfo()
 {
     return $this->_multishipping->getQuote()->getPayment();
 }
Esempio n. 8
0
 /**
  * @param \Magento\Multishipping\Model\Checkout\Type\Multishipping $subject
  * @param array|null $methods
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeSetShippingMethods(\Magento\Multishipping\Model\Checkout\Type\Multishipping $subject, $methods)
 {
     $giftMessages = $this->request->getParam('giftmessage');
     $quote = $subject->getQuote();
     $this->message->add($giftMessages, $quote);
 }