Example #1
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Test exception
  */
 public function testUpdateWithException()
 {
     $currentVersionId = 3;
     $lastVersionId = 1;
     $listId = [2, 3];
     $this->stateMock->expects($this->any())->method('getViewId')->will($this->returnValue(1));
     $this->stateMock->expects($this->once())->method('getVersionId')->will($this->returnValue($lastVersionId));
     $this->stateMock->expects($this->never())->method('setVersionId');
     $this->stateMock->expects($this->exactly(2))->method('getStatus')->will($this->returnValue(\Magento\Framework\Mview\View\StateInterface::STATUS_IDLE));
     $this->stateMock->expects($this->exactly(2))->method('setStatus')->will($this->returnSelf());
     $this->stateMock->expects($this->exactly(2))->method('save')->will($this->returnSelf());
     $this->changelogMock->expects($this->once())->method('getVersion')->will($this->returnValue($currentVersionId));
     $this->changelogMock->expects($this->once())->method('getList')->with($lastVersionId, $currentVersionId)->will($this->returnValue($listId));
     $actionMock = $this->getMock('Magento\\Framework\\Mview\\Action', ['execute'], [], '', false);
     $actionMock->expects($this->once())->method('execute')->with($listId)->will($this->returnCallback(function () {
         throw new \Exception('Test exception');
     }));
     $this->actionFactoryMock->expects($this->once())->method('get')->with('Some\\Class\\Name')->will($this->returnValue($actionMock));
     $this->loadView();
     $this->model->update();
 }