/** * @dataProvider isLockedDataProvider * @param bool $needUnlock */ public function testIsLocked($needUnlock) { $streamLock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\File\\Write')->setMethods(array('unlock'))->disableOriginalConstructor()->getMock(); $this->_processFile = $this->getMock('Magento\\Index\\Model\\Process\\File', array('isProcessLocked', '__wakeup'), array($streamLock)); $this->_processFile->expects($this->once())->method('isProcessLocked')->with($needUnlock)->will($this->returnArgument(0)); $this->_prepareIndexProcess(); $this->assertEquals($needUnlock, $this->_indexProcess->isLocked($needUnlock)); }
/** * @magentoDbIsolation enabled */ public function testReindexAllDoesntTriggerUnprocessedEventFetchingInManualMode() { $collection = $this->_objectManager->create('Magento\\Index\\Model\\Resource\\Event\\Collection'); $this->_model->setMode(\Magento\Index\Model\Process::MODE_REAL_TIME); $this->_model->setStatus(\Magento\Index\Model\Process::STATUS_PENDING); $this->_eventRepositoryMock->expects($this->once())->method('getUnprocessed')->will($this->returnValue($collection)); $this->_eventRepositoryMock->expects($this->never())->method('hasUnprocessed'); $this->_model->reindexAll(); }
/** * Add mass-actions to grid * * @return $this */ protected function _prepareMassaction() { $this->setMassactionIdField('process_id'); $this->getMassactionBlock()->setFormFieldName('process'); $modeOptions = $this->_indexProcess->getModesOptions(); $this->getMassactionBlock()->addItem('change_mode', array('label' => __('Change Index Mode'), 'url' => $this->getUrl('adminhtml/*/massChangeMode'), 'additional' => array('mode' => array('name' => 'index_mode', 'type' => 'select', 'class' => 'required-entry', 'label' => __('Index mode'), 'values' => $modeOptions)))); $this->getMassactionBlock()->addItem('reindex', array('label' => __('Reindex Data'), 'url' => $this->getUrl('adminhtml/*/massReindex'), 'selected' => true)); return $this; }
/** * 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; }
/** * 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; }