Esempio n. 1
0
 public function testGetLatestUpdated()
 {
     $checkValue = 1;
     $indexId = 'indexer_internal_name';
     $this->loadIndexer($indexId);
     $this->viewMock->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->viewMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
     $this->viewMock->expects($this->any())->method('getUpdated')->will($this->returnValue($checkValue));
     $stateMock = $this->getMock('\\Magento\\Indexer\\Model\\Indexer\\State', ['load', 'getId', 'setIndexerId', '__wakeup', 'getUpdated'], [], '', false);
     $stateMock->expects($this->once())->method('getUpdated')->will($this->returnValue(0));
     $this->stateFactoryMock->expects($this->once())->method('create')->will($this->returnValue($stateMock));
     $this->assertEquals($checkValue, $this->model->getLatestUpdated());
 }
 /**
  * @param bool $getViewIsEnabled
  * @param string $getViewGetUpdated
  * @param string $getStateGetUpdated
  * @dataProvider getLatestUpdatedDataProvider
  */
 public function testGetLatestUpdated($getViewIsEnabled, $getViewGetUpdated, $getStateGetUpdated)
 {
     $indexId = 'indexer_internal_name';
     $this->loadIndexer($indexId);
     $this->viewMock->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->viewMock->expects($this->once())->method('isEnabled')->will($this->returnValue($getViewIsEnabled));
     $this->viewMock->expects($this->any())->method('getUpdated')->will($this->returnValue($getViewGetUpdated));
     $stateMock = $this->getMock('\\Magento\\Indexer\\Model\\Indexer\\State', ['load', 'getId', 'setIndexerId', '__wakeup', 'getUpdated'], [], '', false);
     $stateMock->expects($this->any())->method('getUpdated')->will($this->returnValue($getStateGetUpdated));
     $this->stateFactoryMock->expects($this->once())->method('create')->will($this->returnValue($stateMock));
     if ($getViewIsEnabled && $getViewGetUpdated) {
         if (!$getStateGetUpdated) {
             $this->assertEquals($getViewGetUpdated, $this->model->getLatestUpdated());
         } else {
             if ($getViewGetUpdated == $getStateGetUpdated) {
                 $this->assertEquals($getViewGetUpdated, $this->model->getLatestUpdated());
             } else {
                 $this->assertEquals($getViewGetUpdated, $this->model->getLatestUpdated());
             }
         }
     } else {
         $this->assertEquals($getStateGetUpdated, $this->model->getLatestUpdated());
     }
 }