/** * This is a procedural test, testing that the method `ebayenterprise_order/orderrejected::process` * when invoke will call the expected methods and pass in the expected parameteWr values. */ public function testUpdateRejectedStatus() { $id = 5; $eventName = 'OrderRejected'; $order = $this->getModelMock('sales/order', ['loadByIncrementId']); $order->setId($id); $order->expects($this->once())->method('loadByIncrementId')->with($this->identicalTo(static::PAYLOAD_CUSTOMER_ORDER_ID))->will($this->returnSelf()); $this->replaceByMock('model', 'sales/order', $order); $this->_eventHelper->expects($this->once())->method('attemptCancelOrder')->with($this->identicalTo($order), $this->identicalTo($eventName))->will($this->returnSelf()); $this->_orderrejected->process(); }
/** * Listen for an order cancel event. * Load a collection using the extracted order increment ids. * Update each order's state and status to 'canceled' and the associated status respectively. * * @param Varien_Event_Observer * @return void */ public function handleEbayEnterpriseOrderEventCancel(Varien_Event_Observer $observer) { $message = trim($observer->getEvent()->getMessage()); $orderCollection = $this->loadOrdersFromXml($message); $eventName = $observer->getEvent()->getName(); foreach ($orderCollection as $order) { $this->orderEventHelper->attemptCancelOrder($order, $eventName); } }
/** * Processing order rejected event by loading the order using the customer order id * from the payload, if we have a valid order in Magento we proceed to attempt * to cancel the order. * @return self */ public function process() { $incrementId = trim($this->_payload->getCustomerOrderId()); if ($incrementId === '') { $logMessage = 'Received empty customer order id.'; $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__)); return $this; } $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); if (!$order->getId()) { $logData = ['increment_Id' => $incrementId]; $logMessage = 'Customer order id {increment_id} was not found.'; $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData)); return $this; } // canceling the order $this->_orderEventHelper->attemptCancelOrder($order, $this->_payload->getEventType()); return $this; }