Example #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);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getResponse()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getResponse');
     if (!$pluginInfo) {
         return parent::getResponse();
     } else {
         return $this->___callPlugins('getResponse', func_get_args(), $pluginInfo);
     }
 }
Example #3
0
 /**
  * @dataProvider executeDataProvider
  * @param int $formId
  * @param int $callsNumber
  */
 public function testExecute($formId, $callsNumber)
 {
     $content = ['formId' => $formId];
     $blockMethods = ['setFormId', 'setIsAjax', 'toHtml'];
     $blockMock = $this->getMock('Magento\\Captcha\\Block\\Captcha', $blockMethods, [], '', false);
     $this->requestMock->expects($this->any())->method('getPost')->with('formId')->will($this->returnValue($formId));
     $this->requestMock->expects($this->exactly($callsNumber))->method('getContent')->will($this->returnValue(json_encode($content)));
     $this->captchaHelperMock->expects($this->any())->method('getCaptcha')->with($formId)->will($this->returnValue($this->captchaMock));
     $this->captchaMock->expects($this->once())->method('generate');
     $this->captchaMock->expects($this->once())->method('getBlockName')->will($this->returnValue('block'));
     $this->captchaMock->expects($this->once())->method('getImgSrc')->will($this->returnValue('source'));
     $this->layoutMock->expects($this->once())->method('createBlock')->with('block')->will($this->returnValue($blockMock));
     $blockMock->expects($this->any())->method('setFormId')->with($formId)->will($this->returnValue($blockMock));
     $blockMock->expects($this->any())->method('setIsAjax')->with(true)->will($this->returnValue($blockMock));
     $blockMock->expects($this->once())->method('toHtml');
     $this->responseMock->expects($this->once())->method('representJson')->with(json_encode(['imgSrc' => 'source']));
     $this->flagMock->expects($this->once())->method('set')->with('', 'no-postDispatch', true);
     $this->model->execute();
 }