57 $this->requestMock = $this->getMockBuilder(\
Magento\Framework\
App\Request\Http::class)
58 ->disableOriginalConstructor()
61 $this->responseMock = $this->getMockBuilder(\
Magento\Framework\
App\
Response\Http::class)
62 ->disableOriginalConstructor()
66 $this->sessionMock = $this->getMockBuilder(\
Magento\Backend\Model\Session::class)
67 ->disableOriginalConstructor()
71 $this->actionFlagMock = $this->getMockBuilder(\
Magento\Framework\
App\ActionFlag::class)
72 ->disableOriginalConstructor()
76 $this->objectManagerMock = $this->createMock(\
Magento\Framework\ObjectManagerInterface::class);
78 $contextMock = $this->getMockBuilder(\
Magento\Backend\
App\
Action\Context::class)
79 ->disableOriginalConstructor()
82 $contextMock->expects($this->any())
83 ->method(
'getRequest')
84 ->will($this->returnValue($this->requestMock));
85 $contextMock->expects($this->any())
86 ->method(
'getResponse')
87 ->will($this->returnValue($this->responseMock));
88 $contextMock->expects($this->any())
89 ->method(
'getSession')
90 ->will($this->returnValue($this->sessionMock));
91 $contextMock->expects($this->any())
92 ->method(
'getActionFlag')
93 ->will($this->returnValue($this->actionFlagMock));
94 $contextMock->expects($this->any())
95 ->method(
'getObjectManager')
96 ->will($this->returnValue($this->objectManagerMock));
98 $this->fileFactory = $this->getMockBuilder(\
Magento\Framework\
App\
Response\Http\FileFactory::class)
99 ->disableOriginalConstructor()
104 \
Magento\Sales\Controller\Adminhtml\Order\Invoice\PrintAction::class,
106 'context' => $contextMock,
107 'fileFactory' => $this->fileFactory
116 $this->requestMock->expects($this->once())
119 ->will($this->returnValue($invoiceId));
121 $invoiceMock = $this->createMock(\
Magento\Sales\Model\Order\Invoice::class);
123 $pdfMock = $this->createPartialMock(\
Magento\Sales\Model\Order\Pdf\Invoice::class, [
'render',
'getPdf']);
124 $pdfMock->expects($this->once())
127 $pdfMock->expects($this->once())
129 $dateTimeMock = $this->createMock(\
Magento\Framework\Stdlib\DateTime\DateTime::class);
132 ->disableOriginalConstructor()
136 ->willReturn($invoiceMock);
138 $this->objectManagerMock->expects($this->at(0))
140 ->with(\
Magento\Sales\Api\InvoiceRepositoryInterface::class)
142 $this->objectManagerMock->expects($this->at(1))
144 ->with(\
Magento\Sales\Model\Order\Pdf\Invoice::class)
145 ->willReturn($pdfMock);
146 $this->objectManagerMock->expects($this->at(2))
148 ->with(\
Magento\Framework\Stdlib\DateTime\DateTime::class)
149 ->willReturn($dateTimeMock);
151 $this->assertNull($this->controller->execute());