/** * {@inheritdoc} */ public function dispatch(\Magento\Framework\App\RequestInterface $request) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'dispatch'); if (!$pluginInfo) { return parent::dispatch($request); } else { return $this->___callPlugins('dispatch', func_get_args(), $pluginInfo); } }
/** * Test execute exception * * @return void */ public function testExecuteException() { $response = ['error' => true, 'message' => 'Cannot add new comment.']; $e = new \Exception('test'); $this->requestMock->expects($this->once())->method('getParam')->will($this->throwException($e)); $this->resultJsonFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->resultJsonMock)); $this->resultJsonMock->expects($this->once())->method('setData')->with($response); $this->assertSame($this->resultJsonMock, $this->controller->execute()); }
public function testExecuteException() { $response = ['error' => true, 'message' => 'Cannot add new comment.']; $e = new \Exception('test'); $this->requestMock->expects($this->once())->method('getParam')->will($this->throwException($e)); $helperMock = $this->getMockBuilder('Magento\\Core\\Helper\\Data')->disableOriginalConstructor()->setMethods([])->getMock(); $helperMock->expects($this->once())->method('jsonEncode')->with($response)->will($this->returnValue(json_encode($response))); $this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Core\\Helper\\Data')->will($this->returnValue($helperMock)); $this->responseMock->expects($this->once())->method('representJson')->with(json_encode($response)); $this->assertNull($this->controller->execute()); }