21 private $resultRedirect;
26 private $messageManager;
31 private $orderCollectionFactoryMock;
36 private $orderCollectionMock;
48 $objectManagerHelper =
new ObjectManagerHelper($this);
50 $this->messageManager = $this->createPartialMock(
51 \
Magento\Framework\Message\Manager::class,
52 [
'addSuccessMessage',
'addErrorMessage']
55 $this->orderCollectionMock = $this->createMock(\
Magento\Sales\Model\
ResourceModel\Order\Collection::class);
56 $this->filterMock = $this->createMock(\
Magento\Ui\Component\MassAction\Filter::class);
58 $this->orderCollectionFactoryMock = $this->createPartialMock(
63 $this->orderCollectionFactoryMock
64 ->expects($this->once())
66 ->willReturn($this->orderCollectionMock);
67 $this->resultRedirect = $this->createMock(\
Magento\Backend\Model\View\Result\Redirect::class);
68 $resultRedirectFactory = $this->createMock(\
Magento\Framework\Controller\ResultFactory::class);
69 $resultRedirectFactory->expects($this->any())->method(
'create')->willReturn($this->resultRedirect);
70 $this->controller = $objectManagerHelper->getObject(
71 \
Magento\Sales\Controller\Adminhtml\Order\Pdfinvoices::class,
73 'filter' => $this->filterMock,
74 'resultFactory' => $resultRedirectFactory,
75 'messageManager' => $this->messageManager
79 ->setBackwardCompatibleProperty(
81 'orderCollectionFactory',
82 $this->orderCollectionFactoryMock
91 $exception = new \Exception();
93 ->expects($this->once())
94 ->method(
'getCollection')
95 ->with($this->orderCollectionMock)
96 ->willThrowException($exception);
97 $this->messageManager->expects($this->once())->method(
'addErrorMessage');
99 $this->resultRedirect->expects($this->once())->method(
'setPath')->willReturnSelf();
100 $this->controller->execute($exception);