Example #1
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'execute');
     if (!$pluginInfo) {
         return parent::execute();
     } else {
         return $this->___callPlugins('execute', func_get_args(), $pluginInfo);
     }
 }
 public function testSaveActionThrowsException()
 {
     $this->requestMock->expects($this->any())->method('getPostValue')->willReturn(['page_id' => $this->pageId]);
     $this->requestMock->expects($this->atLeastOnce())->method('getParam')->willReturnMap([['page_id', null, $this->pageId], ['back', null, true]]);
     $this->dataProcessorMock->expects($this->any())->method('filter')->willReturnArgument(0);
     $this->objectManagerMock->expects($this->atLeastOnce())->method('create')->with($this->equalTo('Magento\\Cms\\Model\\Page'))->willReturn($this->pageMock);
     $this->pageMock->expects($this->any())->method('load')->willReturnSelf();
     $this->pageMock->expects($this->any())->method('getId')->willReturn(true);
     $this->pageMock->expects($this->once())->method('setData');
     $this->pageMock->expects($this->once())->method('save')->willThrowException(new \Exception('Error message.'));
     $this->messageManagerMock->expects($this->never())->method('addSuccess');
     $this->messageManagerMock->expects($this->once())->method('addException');
     $this->dataPersistorMock->expects($this->any())->method('set')->with('cms_page', ['page_id' => $this->pageId]);
     $this->resultRedirect->expects($this->atLeastOnce())->method('setPath')->with('*/*/edit', ['page_id' => $this->pageId])->willReturnSelf();
     $this->assertSame($this->resultRedirect, $this->saveController->execute());
 }