Example #1
0
 /**
  * Run test execute method
  */
 public function testExecute()
 {
     $orderId = 1;
     $shipmentId = 1;
     $shipment = [];
     $tracking = [];
     $result = 'result-html';
     $layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', ['createBlock'], [], '', false);
     $gridMock = $this->getMock('Magento\\Shipping\\Block\\Adminhtml\\Order\\Packaging\\Grid', ['setIndex', 'toHtml'], [], '', false);
     $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->will($this->returnValue($orderId));
     $this->requestMock->expects($this->at(1))->method('getParam')->with('shipment_id')->will($this->returnValue($shipmentId));
     $this->requestMock->expects($this->at(2))->method('getParam')->with('shipment')->will($this->returnValue($shipment));
     $this->requestMock->expects($this->at(3))->method('getParam')->with('tracking')->will($this->returnValue($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');
     $layoutMock->expects($this->once())->method('createBlock')->with('Magento\\Shipping\\Block\\Adminhtml\\Order\\Packaging\\Grid')->will($this->returnValue($gridMock));
     $this->viewMock->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock));
     $this->responseMock->expects($this->once())->method('setBody')->with($result)->will($this->returnSelf());
     $this->requestMock->expects($this->at(4))->method('getParam')->with('index');
     $gridMock->expects($this->once())->method('setIndex')->will($this->returnSelf());
     $gridMock->expects($this->once())->method('toHtml')->will($this->returnValue($result));
     $this->assertNotEmpty('result-html', $this->controller->execute());
 }
Example #2
0
 protected function _getTreeBlock()
 {
     $this->chooserBlockMock = $this->getMock('Magento\\Catalog\\Block\\Adminhtml\\Category\\Widget\\Chooser', array(), array(), '', false);
     $this->layoutMock = $this->getMock('Magento\\Core\\Model\\Layout', array('createBlock'), array(), '', false);
     $this->layoutMock->expects($this->once())->method('createBlock')->will($this->returnValue($this->chooserBlockMock));
     $this->viewMock->expects($this->once())->method('getLayout')->will($this->returnValue($this->layoutMock));
 }
Example #3
0
 /**
  * Run test execute method
  */
 public function testExecute()
 {
     $orderId = 1;
     $shipmentId = 1;
     $shipment = [];
     $tracking = [];
     $incrementId = '10000001';
     $comeFrom = true;
     $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->will($this->returnValue($orderId));
     $this->requestMock->expects($this->at(1))->method('getParam')->with('shipment_id')->will($this->returnValue($shipmentId));
     $this->requestMock->expects($this->at(2))->method('getParam')->with('shipment')->will($this->returnValue($shipment));
     $this->requestMock->expects($this->at(3))->method('getParam')->with('tracking')->will($this->returnValue($tracking));
     $this->requestMock->expects($this->at(4))->method('getParam')->with('come_from')->will($this->returnValue($comeFrom));
     $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('getIncrementId')->will($this->returnValue($incrementId));
     $menuBlockMock = $this->getMock('Magento\\Backend\\Block\\Menu', ['getParentItems', 'getMenuModel'], [], '', false);
     $menuBlockMock->expects($this->any())->method('getMenuModel')->will($this->returnSelf());
     $menuBlockMock->expects($this->any())->method('getParentItems')->with('Magento_Sales::sales_order')->will($this->returnValue([]));
     $shipmentBlockMock = $this->getMock('Magento\\Shipping\\Block\\Adminhtml\\View', ['updateBackButtonUrl'], [], '', false);
     $layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', ['getBlock'], [], '', false);
     $shipmentBlockMock->expects($this->once())->method('updateBackButtonUrl')->with($comeFrom)->will($this->returnSelf());
     $layoutMock->expects($this->at(0))->method('getBlock')->with('sales_shipment_view')->will($this->returnValue($shipmentBlockMock));
     $layoutMock->expects($this->at(1))->method('getBlock')->with('menu')->will($this->returnValue($menuBlockMock));
     $this->viewMock->expects($this->once())->method('loadLayout')->will($this->returnSelf());
     $this->viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock));
     $this->viewMock->expects($this->once())->method('renderLayout')->will($this->returnSelf());
     $this->assertNull($this->controller->execute());
 }
Example #4
0
 /**
  * Run test execute method
  */
 public function testExecute()
 {
     $data = ['comment' => 'comment'];
     $result = 'result-html';
     $orderId = 1;
     $shipmentId = 1;
     $shipment = [];
     $tracking = [];
     $layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', ['getBlock'], [], '', false);
     $blockMock = $this->getMock('Magento\\Shipping\\Block\\Adminhtml\\View\\Comments', ['toHtml'], [], '', false);
     $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->titleMock->expects($this->once())->method('add');
     $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->shipmentSenderMock->expects($this->once())->method('send');
     $this->shipmentMock->expects($this->once())->method('save');
     $this->viewMock->expects($this->once())->method('loadLayout')->with(false);
     $this->viewMock->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock));
     $layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($blockMock));
     $blockMock->expects($this->once())->method('toHtml')->will($this->returnValue($result));
     $this->responseMock->expects($this->once())->method('setBody')->with($result);
     $this->assertNull($this->controller->execute());
 }
Example #5
0
 /**
  * Run test execute method
  */
 public function testExecute()
 {
     $response = 'html-data';
     $this->shipmentLoad();
     $this->shipmentLoaderMock->expects($this->once())->method('load')->will($this->returnValue($this->shipmentMock));
     $this->shipmentTrackMock->expects($this->once())->method('delete')->will($this->returnSelf());
     $layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', ['getBlock'], [], '', false);
     $trackingBlockMock = $this->getMock('Magento\\Shipping\\Block\\Adminhtml\\Order\\Tracking', ['toHtml'], [], '', false);
     $trackingBlockMock->expects($this->once())->method('toHtml')->will($this->returnValue($response));
     $layoutMock->expects($this->once())->method('getBlock')->with('shipment_tracking')->will($this->returnValue($trackingBlockMock));
     $this->viewMock->expects($this->once())->method('loadLayout')->will($this->returnSelf());
     $this->viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock));
     $this->responseMock->expects($this->once())->method('setBody')->with($response);
     $this->assertNull($this->controller->execute());
 }
Example #6
0
 public function testLoadLayoutWhenBlockIsNotGenerate()
 {
     $this->_layoutMock->expects($this->never())->method('generateElements');
     $this->_view->loadLayout(null, false, true);
 }