/** * {@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 testExecuteNoOrdersPutOnHold() { $order1 = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock(); $order2 = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock(); $orders = [$order1, $order2]; $countOrders = count($orders); $this->orderCollectionMock->expects($this->any())->method('getItems')->willReturn($orders); $order1->expects($this->once())->method('canHold')->willReturn(false); $this->orderCollectionMock->expects($this->once())->method('count')->willReturn($countOrders); $order2->expects($this->once())->method('canHold')->willReturn(false); $this->messageManagerMock->expects($this->once())->method('addError')->with('No order(s) were put on hold.'); $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf(); $this->massAction->execute(); }
public function testExecuteOneOrderCannotBePutOnHold() { $excluded = [1, 2]; $countOrders = count($excluded); $order1 = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock(); $order2 = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock(); $this->requestMock->expects($this->at(0))->method('getParam')->with('selected')->willReturn([]); $this->requestMock->expects($this->at(1))->method('getParam')->with('excluded')->willReturn($excluded); $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Sales\\Model\\Resource\\Order\\Grid\\Collection')->willReturn($this->orderCollectionMock); $this->orderCollectionMock->expects($this->once())->method('addFieldToFilter')->with(\Magento\Sales\Controller\Adminhtml\Order\MassCancel::ID_FIELD, ['nin' => $excluded]); $this->orderCollectionMock->expects($this->any())->method('getItems')->willReturn([$order1, $order2]); $order1->expects($this->once())->method('canHold')->willReturn(false); $this->orderCollectionMock->expects($this->once())->method('count')->willReturn($countOrders); $order2->expects($this->once())->method('canHold')->willReturn(false); $this->messageManagerMock->expects($this->once())->method('addError')->with('No order(s) were put on hold.'); $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf(); $this->massAction->execute(); }