protected function setUp() { $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->_eventRepositoryMock = $this->getMock('Magento\\Index\\Model\\EventRepository', array(), array(), '', false); // get existing indexer process $this->_model = $this->_objectManager->create('Magento\\Index\\Model\\Process', array('eventRepository' => $this->_eventRepositoryMock)); $this->_model->load(self::INDEXER_CODE, 'indexer_code'); if ($this->_model->isObjectNew()) { $this->markTestIncomplete('Can\'t run test without ' . self::INDEXER_CODE . ' indexer.'); } // get new process file instance for current indexer /** @var $lockStorage \Magento\Index\Model\Lock\Storage */ $lockStorage = $this->_objectManager->create('Magento\\Index\\Model\\Lock\\Storage'); $this->_processFile = $lockStorage->getFile($this->_model->getId()); }
/** * Add filter by process and status to events collection * * @param int|array|Process $process * @param string $status * @return $this */ public function addProcessFilter($process, $status = null) { $this->_joinProcessEventTable(); if ($process instanceof Process) { $this->addFieldToFilter('process_event.process_id', $process->getId()); } elseif (is_array($process) && !empty($process)) { $this->addFieldToFilter('process_event.process_id', array('in' => $process)); } else { $this->addFieldToFilter('process_event.process_id', $process); } if ($status !== null) { if (is_array($status) && !empty($status)) { $this->addFieldToFilter('process_event.status', array('in' => $status)); } else { $this->addFieldToFilter('process_event.status', $status); } } return $this; }
/** * Update process end date * * @param ModelProcess $process * @return $this */ public function updateProcessEndDate(ModelProcess $process) { $this->_updateProcessData($process->getId(), array('ended_at' => $this->dateTime->formatDate(time()))); return $this; }
/** * Get row edit url * * @param \Magento\Index\Model\Process $row * * @return string */ public function getRowUrl($row) { return $this->getUrl('adminhtml/*/edit', array('process' => $row->getId())); }
/** * Update status for events of process * * @param int|array|ProcessModel $process * @param string $status * @return $this */ public function updateProcessEvents($process, $status = ProcessModel::EVENT_STATUS_DONE) { $whereCondition = ''; if ($process instanceof ProcessModel) { $whereCondition = array('process_id = ?' => $process->getId()); } elseif (is_array($process) && !empty($process)) { $whereCondition = array('process_id IN (?)' => $process); } elseif (!is_array($whereCondition)) { $whereCondition = array('process_id = ?' => $process); } $this->_getWriteAdapter()->update($this->getTable('index_process_event'), array('status' => $status), $whereCondition); return $this; }