public function testEmail() { $cmId = 10000031; $cmManagement = 'Magento\Sales\Api\CreditmemoManagementInterface'; $cmManagementMock = $this->getMock($cmManagement, [], [], '', false); $this->prepareRedirect($cmId); $this->request->expects($this->once()) ->method('getParam') ->with('creditmemo_id') ->willReturn($cmId); $this->objectManager->expects($this->once()) ->method('create') ->with($cmManagement) ->willReturn($cmManagementMock); $cmManagementMock->expects($this->once()) ->method('notify') ->willReturn(true); $this->messageManager->expects($this->once()) ->method('addSuccess') ->with('You sent the message.'); $this->assertInstanceOf( 'Magento\Backend\Model\View\Result\Redirect', $this->creditmemoEmail->executeInternal() ); $this->assertEquals($this->response, $this->creditmemoEmail->getResponse()); }
public function testEmail() { $cmId = 10000031; $creditmemoClassName = 'Magento\\Sales\\Model\\Order\\Creditmemo'; $cmNotifierClassName = 'Magento\\Sales\\Model\\Order\\CreditmemoNotifier'; $creditmemo = $this->getMock($creditmemoClassName, ['load', '__wakeup'], [], '', false); $cmNotifier = $this->getMock($cmNotifierClassName, ['notify', '__wakeup'], [], '', false); $this->request->expects($this->once())->method('getParam')->with('creditmemo_id')->will($this->returnValue($cmId)); $this->objectManager->expects($this->at(0))->method('create')->with($creditmemoClassName)->will($this->returnValue($creditmemo)); $creditmemo->expects($this->once())->method('load')->with($cmId)->will($this->returnSelf()); $this->objectManager->expects($this->at(1))->method('create')->with($cmNotifierClassName)->will($this->returnValue($cmNotifier)); $cmNotifier->expects($this->once())->method('notify')->will($this->returnValue(true)); $this->messageManager->expects($this->once())->method('addSuccess')->with('We sent the message.'); $this->prepareRedirect($cmId); $this->creditmemoEmail->execute(); $this->assertEquals($this->response, $this->creditmemoEmail->getResponse()); }