@@ -273,6 +273,56 @@ function () {
273273 $ this ->model ->reindexAll ();
274274 }
275275
276+ /**
277+ * @expectedException \Error
278+ * @expectedExceptionMessage Test Engine Error
279+ */
280+ public function testReindexAllWithError ()
281+ {
282+
283+ $ indexId = 'indexer_internal_name ' ;
284+ $ this ->loadIndexer ($ indexId );
285+
286+ $ stateMock = $ this ->createPartialMock (
287+ \Magento \Indexer \Model \Indexer \State::class,
288+ ['load ' , 'getId ' , 'setIndexerId ' , '__wakeup ' , 'getStatus ' , 'setStatus ' , 'save ' ]
289+ );
290+ $ stateMock ->expects ($ this ->once ())->method ('load ' )->with ($ indexId , 'indexer_id ' )->will ($ this ->returnSelf ());
291+ $ stateMock ->expects ($ this ->never ())->method ('setIndexerId ' );
292+ $ stateMock ->expects ($ this ->once ())->method ('getId ' )->will ($ this ->returnValue (1 ));
293+ $ stateMock ->expects ($ this ->exactly (2 ))->method ('setStatus ' )->will ($ this ->returnSelf ());
294+ $ stateMock ->expects ($ this ->once ())->method ('getStatus ' )->will ($ this ->returnValue ('idle ' ));
295+ $ stateMock ->expects ($ this ->exactly (2 ))->method ('save ' )->will ($ this ->returnSelf ());
296+ $ this ->stateFactoryMock ->expects ($ this ->once ())->method ('create ' )->will ($ this ->returnValue ($ stateMock ));
297+
298+ $ this ->viewMock ->expects ($ this ->once ())->method ('isEnabled ' )->will ($ this ->returnValue (false ));
299+ $ this ->viewMock ->expects ($ this ->never ())->method ('suspend ' );
300+ $ this ->viewMock ->expects ($ this ->once ())->method ('resume ' );
301+
302+ $ actionMock = $ this ->createPartialMock (
303+ \Magento \Framework \Indexer \ActionInterface::class,
304+ ['executeFull ' , 'executeList ' , 'executeRow ' ]
305+ );
306+ $ actionMock ->expects ($ this ->once ())->method ('executeFull ' )->will (
307+ $ this ->returnCallback (
308+ function () {
309+ throw new \Error ('Test Engine Error ' );
310+ }
311+ )
312+ );
313+ $ this ->actionFactoryMock ->expects (
314+ $ this ->once ()
315+ )->method (
316+ 'create '
317+ )->with (
318+ 'Some\Class\Name '
319+ )->will (
320+ $ this ->returnValue ($ actionMock )
321+ );
322+
323+ $ this ->model ->reindexAll ();
324+ }
325+
276326 protected function getIndexerData ()
277327 {
278328 return [
0 commit comments