Exemplo n.º 1
0
 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());
 }