/** * @dataProvider isLockedDataProvider * @param bool $needUnlock */ public function testIsLocked($needUnlock) { $this->_processFile = $this->getMock('Mage_Index_Model_Process_File', array('isProcessLocked')); $this->_processFile->expects($this->once())->method('isProcessLocked')->with($needUnlock)->will($this->returnArgument(0)); $this->_prepareIndexProcess(); $this->assertEquals($needUnlock, $this->_indexProcess->isLocked($needUnlock)); }
public function testIsProcessLockedFalseWithoutUnlock() { $this->_openFile(); $this->assertFalse($this->_model->isProcessLocked()); $this->assertFalse($this->_tryGetSharedLock(), 'File must be locked'); $this->assertAttributeSame(true, '_streamLocked', $this->_model); $this->_model->processUnlock(); }
public function testSafeProcessEventException() { // prepare mock that throws exception /** @var $eventMock Mage_Index_Model_Event */ $eventMock = $this->getMock('Mage_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)); }