예제 #1
0
 /**
  * {@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);
     }
 }
예제 #2
0
 /**
  * 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());
 }
예제 #3
0
 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());
 }