/**
  * When getting an order address for an item, if the item does not yet have
  * a loaded order address instance, load a new one and return it.
  */
 public function testGetOrderAddress()
 {
     $addressId = 3;
     $this->_item->setOrderAddressId($addressId);
     $address = Mage::getModel('sales/order_address');
     $this->_multishippingFactory->method('loadAddressForItem')->with($this->identicalTo($this->_item))->will($this->returnValue($address));
     $this->assertSame($address, $this->_item->getOrderAddress());
 }
 /**
  * Stub out dependencies to get through a very basic completion of an order
  * submit.
  *
  * @return self
  */
 protected function _stubForBasicOrderSubmitCompletion()
 {
     // Stubs to get through submit order. Assertions related to these stubs
     // will be covered in more targeted tests.
     $this->_customerSession->method('isLoggedIn')->will($this->returnValue(false));
     $this->_multishippingFactory->method('createOrderSaveTransaction')->will($this->returnValue($this->_transaction));
     $this->_order->method('addData')->will($this->returnSelf());
     $this->_order->method('collectShipmentAmounts')->will($this->returnSelf());
     $this->_order->method('getItemsCollection')->will($this->returnValue([]));
     $this->_order->method('setId')->will($this->returnSelf());
     $this->_order->method('setPayment')->will($this->returnSelf());
     $this->_order->method('setQuote')->will($this->returnSelf());
     $this->_quote->method('getAllAddresses')->will($this->returnValue([]));
     $this->_quote->method('getCustomer')->will($this->returnValue($this->_customer));
     $this->_quote->method('getPayment')->will($this->returnValue($this->_quotePayment));
     $this->_quoteConvertor->method('paymentToOrderPayment')->will($this->returnValue($this->_orderPayment));
     $this->_quoteConvertor->method('toOrder')->will($this->returnValue($this->_order));
     return $this;
 }
 protected function setUp()
 {
     // Stub log context builder to prevent session hits while collecting
     // log context meta-data.
     $logContext = $this->getHelperMock('ebayenterprise_magelog/context', ['getMetaData']);
     $logContext->method('getMetaData')->will($this->returnValue([]));
     $this->_quote = $this->getModelMock('sales/quote', ['getId', 'save']);
     $this->_order = $this->getModelMock('sales/order', ['getCanSendNewEmailFlag', 'queueNewOrderEmail', 'getId', 'getIncrementId']);
     $this->_quoteService = $this->getModelMockBuilder('sales/service_quote')->disableOriginalConstructor()->setMethods(['submitOrder', 'setCheckoutDispatcher'])->getMock();
     $this->_multishippingFactory = $this->getHelperMock('ebayenterprise_multishipping/factory', ['createQuoteService']);
     $this->_multishippingFactory->method('createQuoteService')->with($this->identicalTo($this->_quote), $this->isTrue())->will($this->returnValue($this->_quoteService));
     $this->_checkoutSession = $this->getModelMockBuilder('checkout/session')->disableOriginalConstructor()->setMethods(['setLastQuoteId'])->getMock();
     $this->_coreSession = $this->getModelMockBuilder('core/session')->disableOriginalConstructor()->setMethods(['setOrderIds'])->getMock();
     // Create the multishipping checkout type model to test - mocked to
     // prevent the need for complex mocking for inherited behaviors.
     $builder = $this->getModelMockBuilder('checkout/type_multishipping')->setMethods(['_validate', '_init', 'getQuote'])->setConstructorArgs([['multishipping_factory' => $this->_multishippingFactory, 'log_context' => $logContext, 'core_session' => $this->_coreSession, 'checkout_session' => $this->_checkoutSession]]);
     $this->_multishippingCheckout = $builder->getMock();
     $this->_multishippingCheckout->method('getQuote')->will($this->returnValue($this->_quote));
     // Disable event dispatch to prevent event handling from causing
     // any unexpected side-effects during the test.
     Mage::app()->disableEvents();
 }
 /**
  * Create an address model with the provided item collection as the address'
  * collection of items.
  *
  * @param Mage_Sales_Model_Resource_Order_Item_Collection
  * @return EbayEnterprise_Multishipping_Override_Model_Sales_Order_Address
  */
 protected function _createAddressWithItems(Mage_Sales_Model_Resource_Order_Item_Collection $itemCollection)
 {
     $address = Mage::getModel('sales/order_address', ['multishipping_factory' => $this->_multishippingFactory]);
     $this->_multishippingFactory->method('createItemCollectionForAddress')->will($this->returnValue($itemCollection));
     return $address;
 }