62 'sales' => \Magento\Sales\Model\ResourceModel\Report\Order::class
65 $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
67 $this->resultRedirectFactory = $this->createPartialMock(
68 \
Magento\Backend\Model\View\Result\RedirectFactory::class,
71 $this->resultRedirect = $this->createMock(\
Magento\Backend\Model\View\Result\Redirect::class);
73 $this->request = $this->createMock(\
Magento\Framework\
App\RequestInterface::class);
74 $this->response = $this->createPartialMock(
75 \
Magento\Framework\
App\ResponseInterface::class,
76 [
'setRedirect',
'sendResponse']
79 $this->messageManager = $this->createMock(\
Magento\Framework\Message\Manager::class);
83 $this->objectManager = $this->createMock(\
Magento\Framework\ObjectManagerInterface::class);
85 $this->context = $this->createMock(\
Magento\Backend\
App\Action\Context::class);
86 $this->context->expects($this->once())->method(
'getRequest')->willReturn($this->request);
87 $this->context->expects($this->once())->method(
'getResponse')->willReturn($this->response);
88 $this->context->expects($this->once())->method(
'getMessageManager')->willReturn($this->messageManager);
89 $this->context->expects($this->any())->method(
'getObjectManager')->willReturn($this->objectManager);
90 $this->context->expects($this->once())
91 ->method(
'getResultRedirectFactory')
92 ->willReturn($this->resultRedirectFactory);
94 $this->refreshStatisticsController = $objectManagerHelper->getObject(
95 \
Magento\Backend\Controller\Adminhtml\Dashboard\RefreshStatistics::class,
97 'context' => $this->context,
98 'reportTypes' => $reportTypes
107 $this->resultRedirectFactory->expects($this->any())->method(
'create')->willReturn($this->resultRedirect);
109 $this->messageManager->expects($this->once())
110 ->method(
'addSuccessMessage')
111 ->with(
__(
'We updated lifetime statistic.'));
113 $this->objectManager->expects($this->any())
116 ->willReturn($this->order);
118 $this->resultRedirect->expects($this->once())
123 $this->assertInstanceOf(
124 \
Magento\Backend\Model\View\Result\Redirect::class,
125 $this->refreshStatisticsController->execute()
$refreshStatisticsController