public function testEmailNoOrderId() { $this->request->expects($this->once()) ->method('getParam') ->with('order_id') ->will($this->returnValue(null)); $this->orderRepositoryMock->expects($this->once()) ->method('get') ->with(null) ->willThrowException( new \Magento\Framework\Exception\NoSuchEntityException(__('Requested entity doesn\'t exist')) ); $this->messageManager->expects($this->once()) ->method('addError') ->with('This order no longer exists.'); $this->actionFlag->expects($this->once()) ->method('set') ->with('', 'no-dispatch', true) ->will($this->returnValue(true)); $this->resultRedirect->expects($this->once()) ->method('setPath') ->with('sales/*/') ->willReturnSelf(); $this->assertInstanceOf( 'Magento\Backend\Model\View\Result\Redirect', $this->orderEmail->executeInternal() ); }
/** * {@inheritdoc} */ public function dispatch(\Magento\Framework\App\RequestInterface $request) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'dispatch'); if (!$pluginInfo) { return parent::dispatch($request); } else { return $this->___callPlugins('dispatch', func_get_args(), $pluginInfo); } }
public function testEmailNoOrderId() { $orderClassName = 'Magento\\Sales\\Model\\Order'; $order = $this->getMock($orderClassName, ['load', 'getId', '__wakeup'], [], '', false); $this->request->expects($this->once())->method('getParam')->with('order_id')->will($this->returnValue(null)); $this->objectManager->expects($this->at(0))->method('create')->with($orderClassName)->will($this->returnValue($order)); $order->expects($this->once())->method('load')->with(null)->will($this->returnSelf()); $this->messageManager->expects($this->once())->method('addError')->with('This order no longer exists.'); $this->actionFlag->expects($this->once())->method('set')->with('', 'no-dispatch', true)->will($this->returnValue(true)); $this->resultRedirect->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf(); $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Redirect', $this->orderEmail->execute()); }