/**
  * Test process method with shipping_address
  */
 public function testProcessShippingAddress()
 {
     $this->orderMock->expects($this->exactly(2))->method('getAddressesCollection')->will($this->returnValue($this->addressCollectionMock));
     $this->addressCollectionMock->expects($this->once())->method('save')->will($this->returnSelf());
     $this->orderMock->expects($this->once())->method('getBillingAddress')->will($this->returnValue(null));
     $this->orderMock->expects($this->once())->method('getShippingAddress')->will($this->returnValue($this->addressMock));
     $this->addressMock->expects($this->exactly(2))->method('getId')->will($this->returnValue(2));
     $this->orderMock->expects($this->once())->method('setShippingAddressId')->will($this->returnSelf());
     $this->attributeMock->expects($this->once())->method('saveAttribute')->with($this->orderMock, ['shipping_address_id'])->will($this->returnSelf());
     $this->assertEquals($this->address, $this->address->process($this->orderMock));
 }
Beispiel #2
0
 /**
  * Save order related objects
  *
  * @return $this
  */
 protected function _afterSave()
 {
     if (null !== $this->_addresses) {
         $this->_addresses->save();
         $billingAddress = $this->getBillingAddress();
         $attributesForSave = array();
         if ($billingAddress && $this->getBillingAddressId() != $billingAddress->getId()) {
             $this->setBillingAddressId($billingAddress->getId());
             $attributesForSave[] = 'billing_address_id';
         }
         $shippingAddress = $this->getShippingAddress();
         if ($shippingAddress && $this->getShippigAddressId() != $shippingAddress->getId()) {
             $this->setShippingAddressId($shippingAddress->getId());
             $attributesForSave[] = 'shipping_address_id';
         }
         if (!empty($attributesForSave)) {
             $this->_getResource()->saveAttribute($this, $attributesForSave);
         }
     }
     if (null !== $this->_items) {
         $this->_items->save();
     }
     if (null !== $this->_payments) {
         $this->_payments->save();
     }
     if (null !== $this->_statusHistory) {
         $this->_statusHistory->save();
     }
     foreach ($this->getRelatedObjects() as $object) {
         $object->save();
     }
     return parent::_afterSave();
 }