40 $this->requestMock = $this->createPartialMock(
42 [
'getParam',
'__wakeup']
44 $this->shipmentLoaderMock = $this->createPartialMock(
45 \
Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader::class,
46 [
'setOrderId',
'setShipmentId',
'setShipment',
'setTracking',
'load',
'__wakeup']
48 $this->viewMock = $this->createPartialMock(
50 [
'getLayout',
'renderLayout',
'__wakeup']
52 $this->responseMock = $this->createPartialMock(
54 [
'setBody',
'__wakeup']
57 $contextMock = $this->createPartialMock(
59 [
'getRequest',
'getResponse',
'getView',
'__wakeup']
62 $contextMock->expects($this->any())->method(
'getRequest')->will($this->returnValue($this->requestMock));
63 $contextMock->expects($this->any())->method(
'getResponse')->will($this->returnValue($this->responseMock));
64 $contextMock->expects($this->any())->method(
'getView')->will($this->returnValue($this->viewMock));
66 $this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\GetShippingItemsGrid(
68 $this->shipmentLoaderMock
83 $layoutMock = $this->createPartialMock(\
Magento\Framework\View\Layout::class, [
'createBlock']);
84 $gridMock = $this->createPartialMock(
85 \
Magento\Shipping\Block\Adminhtml\Order\Packaging\Grid::class,
86 [
'setIndex',
'toHtml']
89 $this->requestMock->expects($this->at(0))
92 ->will($this->returnValue($orderId));
93 $this->requestMock->expects($this->at(1))
96 ->will($this->returnValue($shipmentId));
97 $this->requestMock->expects($this->at(2))
101 $this->requestMock->expects($this->at(3))
104 ->will($this->returnValue($tracking));
105 $this->shipmentLoaderMock->expects($this->once())->method(
'setOrderId')->with($orderId);
106 $this->shipmentLoaderMock->expects($this->once())->method(
'setShipmentId')->with($shipmentId);
107 $this->shipmentLoaderMock->expects($this->once())->method(
'setShipment')->with(
$shipment);
108 $this->shipmentLoaderMock->expects($this->once())->method(
'setTracking')->with($tracking);
109 $this->shipmentLoaderMock->expects($this->once())->method(
'load');
110 $layoutMock->expects($this->once())
111 ->method(
'createBlock')
112 ->with(\
Magento\Shipping\Block\Adminhtml\Order\Packaging\Grid::class)
113 ->will($this->returnValue($gridMock));
114 $this->viewMock->expects($this->once())
115 ->method(
'getLayout')
116 ->will($this->returnValue($layoutMock));
117 $this->responseMock->expects($this->once())
120 ->will($this->returnSelf());
121 $this->requestMock->expects($this->at(4))
124 $gridMock->expects($this->once())
126 ->will($this->returnSelf());
127 $gridMock->expects($this->once())
129 ->will($this->returnValue(
$result));
131 $this->assertNotEmpty(
'result-html', $this->controller->execute());
foreach($order->getItems() as $orderItem) $shipment