public function aroundGetViewUrl(\Magento\Sales\Block\Order\History $subject, $procede, $order) { if ($order->getIsFromImport()) { return $subject->getUrl('sales/order/old', ['order_id' => $order->getId()]); } return $procede($order); }
public function testConstructMethod() { $data = []; $customerId = 25; $this->customerSession->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId)); $statuses = ['pending', 'processing', 'comlete']; $this->orderConfig->expects($this->once())->method('getVisibleOnFrontStatuses')->will($this->returnValue($statuses)); $orderCollection = $this->getMock('Magento\\Sales\\Model\\Resource\\Order\\Collection', ['addFieldToSelect', 'addFieldToFilter', 'setOrder'], [], '', false, false); $orderCollection->expects($this->at(0))->method('addFieldToSelect')->with($this->equalTo('*'))->will($this->returnSelf()); $orderCollection->expects($this->at(1))->method('addFieldToFilter')->with('customer_id', $this->equalTo($customerId))->will($this->returnSelf()); $orderCollection->expects($this->at(2))->method('addFieldToFilter')->with('status', $this->equalTo(['in' => $statuses]))->will($this->returnSelf()); $orderCollection->expects($this->at(3))->method('setOrder')->with('created_at', 'desc')->will($this->returnSelf()); $this->orderCollectionFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($orderCollection)); $this->model = new \Magento\Sales\Block\Order\History($this->context, $this->orderCollectionFactory, $this->customerSession, $this->orderConfig, $this->pageConfig, $data); $this->assertEquals($orderCollection, $this->model->getOrders()); }