Exemple #1
0
 public function testGetUnprocessedReturnsConfiguredCollectionOfEvents()
 {
     $process = $this->getMock('Magento\\Index\\Model\\Process', array(), array(), '', false);
     $this->_eventCollection->expects($this->once())->method('addProcessFilter')->with($process, \Magento\Index\Model\Process::EVENT_STATUS_NEW);
     $this->assertEquals($this->_eventCollection, $this->_model->getUnprocessed($process));
 }
Exemple #2
0
 /**
  * Index pending events addressed to the process
  *
  * @param   null|string $entity
  * @param   null|string $type
  * @return  $this
  * @throws \Exception
  */
 public function indexEvents($entity = null, $type = null)
 {
     /**
      * Check if process indexer can match entity code and action type
      */
     if ($entity !== null && $type !== null) {
         if (!$this->getIndexer()->matchEntityAndType($entity, $type)) {
             return $this;
         }
     }
     if ($this->getMode() == self::MODE_MANUAL) {
         return $this;
     }
     if ($this->isLocked()) {
         return $this;
     }
     $this->lock();
     try {
         /**
          * Prepare events collection
          */
         $eventsCollection = $this->_eventRepository->getUnprocessed($this);
         if ($entity !== null) {
             $eventsCollection->addEntityFilter($entity);
         }
         if ($type !== null) {
             $eventsCollection->addTypeFilter($type);
         }
         $this->_processEventsCollection($eventsCollection);
         $this->unlock();
     } catch (\Exception $e) {
         $this->unlock();
         throw $e;
     }
     return $this;
 }