public function testGetUnnotifiedForInstance() { $orderId = 100000512; $entityType = 'order'; $order = $this->getMock('Magento\\Sales\\Model\\Order', ['__wakeup', 'getEntityType', 'getId'], [], '', false); $order->expects($this->once())->method('getEntityType')->will($this->returnValue($entityType)); $order->expects($this->once())->method('getId')->will($this->returnValue($orderId)); $this->connectionMock = $this->collection->getResource()->getReadConnection(); $this->connectionMock->expects($this->exactly(3))->method('prepareSqlCondition')->will($this->returnValueMap([['entity_name', $entityType, 'sql-string'], ['is_customer_notified', 0, 'sql-string'], ['parent_id', $orderId, 'sql-string']])); $result = $this->collection->getUnnotifiedForInstance($order); $this->assertEquals($this->historyItemMock, $result); }
/** * 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(); }