public function testGet() { $actionInterfaceMock = $this->getMockForAbstractClass('Magento\\Framework\\Mview\\ActionInterface', [], '', false); $this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Framework\\Mview\\ActionInterface')->will($this->returnValue($actionInterfaceMock)); $this->model->get('Magento\\Framework\\Mview\\ActionInterface'); $this->assertInstanceOf('Magento\\Framework\\Mview\\ActionInterface', $actionInterfaceMock); }
/** * Materialize view by IDs in changelog * * @return void * @throws \Exception */ public function update() { if ($this->getState()->getMode() == View\StateInterface::MODE_ENABLED && $this->getState()->getStatus() == View\StateInterface::STATUS_IDLE ) { $currentVersionId = $this->getChangelog()->getVersion(); $lastVersionId = $this->getState()->getVersionId(); $ids = $this->getChangelog()->getList($lastVersionId, $currentVersionId); if ($ids) { $action = $this->actionFactory->get($this->getActionClass()); $this->getState()->setStatus(View\StateInterface::STATUS_WORKING)->save(); try { $action->execute($ids); $this->getState()->loadByView($this->getId()); $statusToRestore = $this->getState()->getStatus() == View\StateInterface::STATUS_SUSPENDED ? View\StateInterface::STATUS_SUSPENDED : View\StateInterface::STATUS_IDLE; $this->getState()->setVersionId($currentVersionId)->setStatus($statusToRestore)->save(); } catch (\Exception $exception) { $this->getState()->loadByView($this->getId()); $statusToRestore = $this->getState()->getStatus() == View\StateInterface::STATUS_SUSPENDED ? View\StateInterface::STATUS_SUSPENDED : View\StateInterface::STATUS_IDLE; $this->getState()->setStatus($statusToRestore)->save(); throw $exception; } } } }