public function testLoadByCreditmemoId() { $this->loader->setCreditmemoId(1); $this->loader->setOrderId(1); $this->loader->setCreditmemo('test'); $creditmemoMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Creditmemo')->disableOriginalConstructor()->setMethods([])->getMock(); $this->creditmemoRepositoryMock->expects($this->once())->method('get')->willReturn($creditmemoMock); $this->assertInstanceOf('Magento\\Sales\\Model\\Order\\Creditmemo', $this->loader->load()); }
/** * Run test notify method */ public function testNotify() { $id = 123; $returnValue = 'return-value'; $modelMock = $this->getMockForAbstractClass('Magento\\Sales\\Model\\AbstractModel', [], '', false); $this->creditmemoRepositoryMock->expects($this->once())->method('get')->with($id)->will($this->returnValue($modelMock)); $this->creditmemoNotifierMock->expects($this->once())->method('notify')->with($modelMock)->will($this->returnValue($returnValue)); $this->assertEquals($returnValue, $this->creditmemoService->notify($id)); }
/** * @covers \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\PrintAction::executeInternal */ public function testExecute() { $creditmemoId = 2; $date = '2015-01-19_13-03-45'; $fileName = 'creditmemo2015-01-19_13-03-45.pdf'; $fileContents = 'pdf0123456789'; $this->prepareTestExecute($creditmemoId); $this->objectManagerMock->expects($this->any()) ->method('create') ->willReturnMap( [ ['Magento\Sales\Model\Order\Creditmemo', [], $this->creditmemoMock], ['Magento\Sales\Model\Order\Pdf\Creditmemo', [], $this->creditmemoPdfMock] ] ); $this->creditmemoRepositoryMock->expects($this->once()) ->method('get') ->with($creditmemoId) ->willReturn($this->creditmemoMock); $this->creditmemoPdfMock->expects($this->once()) ->method('getPdf') ->with([$this->creditmemoMock]) ->willReturn($this->pdfMock); $this->objectManagerMock->expects($this->once()) ->method('get') ->with('Magento\Framework\Stdlib\DateTime\DateTime') ->willReturn($this->dateTimeMock); $this->dateTimeMock->expects($this->once()) ->method('date') ->with('Y-m-d_H-i-s') ->willReturn($date); $this->pdfMock->expects($this->once()) ->method('render') ->willReturn($fileContents); $this->fileFactoryMock->expects($this->once()) ->method('create') ->with( $fileName, $fileContents, \Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR, 'application/pdf' ) ->willReturn($this->responseMock); $this->assertInstanceOf( 'Magento\Framework\App\ResponseInterface', $this->printAction->executeInternal() ); }