public function testExecute() { $shipmentId = 1000012; $orderId = 10003; $tracking = []; $shipmentData = ['items' => [], 'send_email' => '']; $shipment = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment', ['load', 'save', 'register', 'getOrder', 'getOrderId', '__wakeup'], [], '', false); $order = $this->getMock('Magento\\Sales\\Model\\Order', ['setCustomerNoteNotify', '__wakeup'], [], '', false); $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([['order_id', null, $orderId], ['shipment_id', null, $shipmentId], ['shipment', null, $shipmentData], ['tracking', null, $tracking]])); $this->shipmentLoader->expects($this->any())->method('setShipmentId')->with($shipmentId); $this->shipmentLoader->expects($this->any())->method('setOrderId')->with($orderId); $this->shipmentLoader->expects($this->any())->method('setShipment')->with($shipmentData); $this->shipmentLoader->expects($this->any())->method('setTracking')->with($tracking); $this->shipmentLoader->expects($this->once())->method('load')->will($this->returnValue($shipment)); $shipment->expects($this->once())->method('register')->will($this->returnSelf()); $shipment->expects($this->any())->method('getOrder')->will($this->returnValue($order)); $order->expects($this->once())->method('setCustomerNoteNotify')->with(false); $this->labelGenerator->expects($this->any())->method('create')->with($shipment, $this->request)->will($this->returnValue(true)); $saveTransaction = $this->getMockBuilder('Magento\\Framework\\DB\\Transaction')->disableOriginalConstructor()->setMethods([])->getMock(); $saveTransaction->expects($this->at(0))->method('addObject')->with($shipment)->will($this->returnSelf()); $saveTransaction->expects($this->at(1))->method('addObject')->with($order)->will($this->returnSelf()); $saveTransaction->expects($this->at(2))->method('save'); $this->session->expects($this->once())->method('getCommentText')->with(true); $this->objectManager->expects($this->once())->method('create')->with('Magento\\Framework\\DB\\Transaction')->will($this->returnValue($saveTransaction)); $this->objectManager->expects($this->once())->method('get')->with('Magento\\Backend\\Model\\Session')->will($this->returnValue($this->session)); $path = 'sales/order/view'; $arguments = ['order_id' => $orderId]; $shipment->expects($this->once())->method('getOrderId')->will($this->returnValue($orderId)); $this->prepareRedirect($path, $arguments); $this->saveAction->execute(); $this->assertEquals($this->response, $this->saveAction->getResponse()); }
/** * {@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); } }