Exemplo n.º 1
0
 public function testIsProcessLockedFalseWithoutUnlock()
 {
     $this->_openFile();
     $this->assertFalse($this->_model->isProcessLocked(false));
     $this->assertFalse($this->_tryGetSharedLock(), 'File must be locked');
     $this->assertAttributeSame(true, '_streamLocked', $this->_model);
     $this->_model->processUnlock();
 }
Exemplo n.º 2
0
 /**
  * @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));
 }
Exemplo n.º 3
0
 public function testSafeProcessEventException()
 {
     // prepare mock that throws exception
     /** @var $eventMock \Magento\Index\Model\Event */
     $eventMock = $this->getMock('Magento\\Index\\Model\\Event', array('setProcess'), array(), '', false);
     $eventMock->setData($this->_indexerMatchData);
     $exceptionMessage = self::EXCEPTION_MESSAGE;
     $eventMock->expects($this->any())->method('setProcess')->will($this->returnCallback(function () use($exceptionMessage) {
         throw new \Exception($exceptionMessage);
     }));
     // can't use @expectedException because we need to assert indexer lock status
     try {
         $this->_model->safeProcessEvent($eventMock);
     } catch (\Exception $e) {
         $this->assertEquals(self::EXCEPTION_MESSAGE, $e->getMessage());
     }
     $this->assertFalse($this->_processFile->isProcessLocked(true));
 }