本文整理汇总了PHP中Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ShipmentLoader::expects方法的具体用法?PHP ShipmentLoader::expects怎么用?PHP ShipmentLoader::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader
的用法示例。
在下文中一共展示了ShipmentLoader::expects方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExecuteLoadShipmentFail
/**
* Run test execute method (fail load shipment model)
*/
public function testExecuteLoadShipmentFail()
{
$this->shipmentLoaderMock->expects($this->once())->method('load')->willThrowException(new \Magento\Framework\Exception\LocalizedException(__('message')));
$this->messageManagerMock->expects($this->once())->method('addError')->will($this->returnSelf());
$this->redirectSection();
$this->assertNull($this->controller->execute());
}
示例2: testEmail
public function testEmail()
{
$shipmentId = 1000012;
$orderId = 10003;
$tracking = [];
$shipment = ['items' => []];
$orderShipment = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment', ['load', 'save', '__wakeup'], [], '', false);
$shipmentNotifierClassName = 'Magento\\Shipping\\Model\\ShipmentNotifier';
$shipmentNotifier = $this->getMock($shipmentNotifierClassName, ['notify', '__wakeup'], [], '', false);
$this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([['order_id', null, $orderId], ['shipment_id', null, $shipmentId], ['shipment', null, $shipment], ['tracking', null, $tracking]]));
$this->shipmentLoader->expects($this->once())->method('setShipmentId')->with($shipmentId);
$this->shipmentLoader->expects($this->once())->method('setOrderId')->with($orderId);
$this->shipmentLoader->expects($this->once())->method('setShipment')->with($shipment);
$this->shipmentLoader->expects($this->once())->method('setTracking')->with($tracking);
$this->shipmentLoader->expects($this->once())->method('load')->will($this->returnValue($orderShipment));
$orderShipment->expects($this->once())->method('save')->will($this->returnSelf());
$this->objectManager->expects($this->once())->method('create')->with($shipmentNotifierClassName)->will($this->returnValue($shipmentNotifier));
$shipmentNotifier->expects($this->once())->method('notify')->with($orderShipment)->will($this->returnValue(true));
$this->messageManager->expects($this->once())->method('addSuccess')->with('You sent the shipment.');
$path = '*/*/view';
$arguments = ['shipment_id' => $shipmentId];
$this->prepareRedirect($path, $arguments, 0);
$this->shipmentEmail->execute();
$this->assertEquals($this->response, $this->shipmentEmail->getResponse());
}
示例3: testExecute
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);
$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));
$this->session->expects($this->once())->method('getCommentText')->with(true)->will($this->returnValue(''));
$this->objectManager->expects($this->atLeastOnce())->method('get')->with('Magento\\Backend\\Model\\Session')->will($this->returnValue($this->session));
$this->view->expects($this->once())->method('loadLayout')->will($this->returnSelf());
$this->view->expects($this->once())->method('renderLayout')->will($this->returnSelf());
$this->view->expects($this->any())->method('getPage')->willReturn($this->resultPageMock);
$this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->pageConfigMock);
$this->pageConfigMock->expects($this->any())->method('getTitle')->willReturn($this->pageTitleMock);
$layout = $this->getMock('Magento\\Framework\\View\\Layout\\Element\\Layout', ['getBlock'], [], '', false);
$menuBlock = $this->getMock('Magento\\Framework\\View\\Element\\BlockInterface', ['toHtml', 'setActive', 'getMenuModel'], [], '', false);
$menuModel = $this->getMockBuilder('Magento\\Backend\\Model\\Menu')->disableOriginalConstructor()->getMock();
$itemId = 'Magento_Sales::sales_order';
$parents = [new \Magento\Framework\DataObject(['title' => 'title1']), new \Magento\Framework\DataObject(['title' => 'title2']), new \Magento\Framework\DataObject(['title' => 'title3'])];
$menuModel->expects($this->once())->method('getParentItems')->with($itemId)->will($this->returnValue($parents));
$menuBlock->expects($this->once())->method('setActive')->with($itemId);
$menuBlock->expects($this->once())->method('getMenuModel')->will($this->returnValue($menuModel));
$this->view->expects($this->once())->method('getLayout')->will($this->returnValue($layout));
$layout->expects($this->once())->method('getBlock')->with('menu')->will($this->returnValue($menuBlock));
$this->assertNull($this->newAction->execute());
}
示例4: loadShipment
protected function loadShipment($orderId, $shipmentId, $shipment, $tracking, $comeFrom, $returnShipment)
{
$valueMap = [['order_id', null, $orderId], ['shipment_id', null, $shipmentId], ['shipment', null, $shipment], ['tracking', null, $tracking], ['come_from', null, $comeFrom]];
$this->requestMock->expects($this->any())->method('getParam')->willReturnMap($valueMap);
$this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId);
$this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId);
$this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment);
$this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking);
$this->shipmentLoaderMock->expects($this->once())->method('load')->willReturn($returnShipment);
}
示例5: testExecuteExceptionSave
/**
* Run test execute method (save exception)
*/
public function testExecuteExceptionSave()
{
$data = ['comment' => 'comment'];
$orderId = 1;
$shipmentId = 1;
$shipment = [];
$tracking = [];
$this->requestMock->expects($this->once())->method('setParam')->with('shipment_id', $shipmentId);
$this->requestMock->expects($this->once())->method('getPost')->with('comment')->will($this->returnValue($data));
$this->requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap([['id', null, $shipmentId], ['order_id', null, $orderId], ['shipment_id', null, $shipmentId], ['shipment', null, $shipment], ['tracking', null, $tracking]]));
$this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId);
$this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId);
$this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment);
$this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking);
$this->shipmentLoaderMock->expects($this->once())->method('load')->will($this->returnValue($this->shipmentMock));
$this->shipmentMock->expects($this->once())->method('addComment');
$this->shipmentCommentSenderMock->expects($this->once())->method('send');
$this->shipmentMock->expects($this->once())->method('save')->will($this->throwException(new \Exception()));
$this->exceptionResponse();
$this->assertNull($this->controller->execute());
}