Skip to content

Commit 6c321ef

Browse files
committed
Fix unit test to match recent changes
1 parent 79f3fc8 commit 6c321ef

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassInvalidateTest.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ class MassInvalidateTest extends \PHPUnit\Framework\TestCase
8080
*/
8181
protected $session;
8282

83+
/**
84+
* @var \Magento\Framework\Controller\Result\Redirect
85+
*/
86+
protected $resultRedirect;
87+
8388
/**
8489
* Set up test
8590
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -100,7 +105,8 @@ protected function setUp()
100105
'getRequest',
101106
'getResponse',
102107
'getObjectManager',
103-
'getMessageManager'
108+
'getMessageManager',
109+
'getResultRedirectFactory',
104110
]);
105111

106112
$this->response = $this->createPartialMock(
@@ -140,6 +146,19 @@ protected function setUp()
140146
false
141147
);
142148

149+
$resultRedirectFactory = $this->createPartialMock(
150+
\Magento\Backend\Model\View\Result\RedirectFactory::class,
151+
['create']
152+
);
153+
$this->resultRedirect = $this->createPartialMock(
154+
\Magento\Framework\Controller\Result\Redirect::class,
155+
['setPath']
156+
);
157+
$this->contextMock->expects($this->any())->method('getResultRedirectFactory')
158+
->willReturn($resultRedirectFactory);
159+
$resultRedirectFactory->expects($this->any())->method('create')
160+
->willReturn($this->resultRedirect);
161+
143162
$this->response->expects($this->any())->method("setRedirect")->willReturn(1);
144163
$this->page = $this->createMock(\Magento\Framework\View\Result\Page::class);
145164
$this->config = $this->createMock(\Magento\Framework\View\Result\Page::class);
@@ -172,7 +191,10 @@ protected function setUp()
172191
*/
173192
public function testExecute($indexerIds, $exception)
174193
{
175-
$this->controller = new \Magento\Indexer\Controller\Adminhtml\Indexer\MassInvalidate($this->contextMock, $this->indexReg);
194+
$this->controller = new \Magento\Indexer\Controller\Adminhtml\Indexer\MassInvalidate(
195+
$this->contextMock,
196+
$this->indexReg
197+
);
176198
$this->request->expects($this->any())
177199
->method('getParam')->with('indexer_ids')
178200
->will($this->returnValue($indexerIds));
@@ -222,9 +244,9 @@ public function testExecute($indexerIds, $exception)
222244

223245
$this->helper->expects($this->any())->method("getUrl")->willReturn("magento.com");
224246
$this->response->expects($this->any())->method("setRedirect")->willReturn(1);
247+
$this->resultRedirect->expects($this->once())->method('setPath')->with('*/*/list');
225248

226-
$result = $this->controller->execute();
227-
$this->assertNull($result);
249+
$this->controller->execute();
228250
}
229251

230252
/**

0 commit comments

Comments
 (0)