Skip to content

Commit 6c47a75

Browse files
committed
Fix unit tests
1 parent 777f409 commit 6c47a75

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@ public function testExecute($indexerIds, $exception)
204204
->method('addError')->with(__('Please select indexers.'))
205205
->will($this->returnValue(1));
206206
} else {
207-
$this->objectManager->expects($this->any())
208-
->method('get')->with(\Magento\Framework\Indexer\IndexerRegistry::class)
209-
->will($this->returnValue($this->indexReg));
210207
$indexerInterface = $this->getMockForAbstractClass(
211208
\Magento\Framework\Indexer\IndexerInterface::class,
212209
['invalidate'],
@@ -226,12 +223,16 @@ public function testExecute($indexerIds, $exception)
226223
->will($this->returnValue(1));
227224

228225
if ($exception) {
226+
$this->indexReg->expects($this->any())
227+
->method('get')->with(2)
228+
->will($this->throwException($exception));
229+
229230
if ($exception instanceof \Magento\Framework\Exception\LocalizedException) {
230-
$this->messageManager->expects($this->exactly(1))
231+
$this->messageManager->expects($this->once())
231232
->method('addError')
232233
->with($exception->getMessage());
233234
} else {
234-
$this->messageManager->expects($this->exactly(1))
235+
$this->messageManager->expects($this->once())
235236
->method('addException')
236237
->with($exception, "We couldn't invalidate indexer(s) because of an error.");
237238
}
@@ -260,11 +261,11 @@ public function executeDataProvider()
260261
'exception' => null,
261262
],
262263
'set3' => [
263-
'indexers' => [1],
264+
'indexers' => [2],
264265
'exception' => new \Magento\Framework\Exception\LocalizedException(__('Test Phrase')),
265266
],
266267
'set4' => [
267-
'indexers' => [1],
268+
'indexers' => [2],
268269
'exception' => new \Exception(),
269270
]
270271
];

0 commit comments

Comments
 (0)