55 $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
56 $this->_helper = $this->createMock(\
Magento\Captcha\Helper\Data::class);
57 $this->_actionFlag = $this->createMock(\
Magento\Framework\
App\ActionFlag::class);
58 $this->_messageManager = $this->createMock(\
Magento\Framework\Message\ManagerInterface::class);
59 $this->redirect = $this->createMock(\
Magento\Framework\
App\
Response\RedirectInterface::class);
60 $this->captchaStringResolver = $this->createMock(\
Magento\Captcha\Observer\CaptchaStringResolver::class);
61 $this->checkForgotpasswordObserver = $this->_objectManager->getObject(
62 \
Magento\Captcha\Observer\CheckForgotpasswordObserver::class,
64 'helper' => $this->_helper,
65 'actionFlag' => $this->_actionFlag,
66 'messageManager' => $this->_messageManager,
67 'redirect' => $this->redirect,
68 'captchaStringResolver' => $this->captchaStringResolver
71 $this->_captcha = $this->createMock(\
Magento\Captcha\Model\DefaultModel::class);
76 $formId =
'user_forgotpassword';
77 $captchaValue =
'some-value';
78 $warningMessage =
'Incorrect CAPTCHA';
79 $redirectRoutePath =
'*/*/forgotpassword';
80 $redirectUrl =
'http://magento.com/customer/account/forgotpassword/';
89 \
Magento\Captcha\Helper\Data::INPUT_NAME_FIELD_VALUE,
92 $this->returnValue([$formId => $captchaValue])
95 $this->redirect->expects(
104 $this->returnValue($redirectUrl)
108 $controller->expects($this->any())->method(
'getRequest')->will($this->returnValue(
$request));
110 $this->_captcha->expects($this->any())->method(
'isRequired')->will($this->returnValue(
true));
111 $this->_captcha->expects(
118 $this->returnValue(
false)
121 $this->captchaStringResolver->expects(
129 $this->returnValue($captchaValue)
132 $this->_helper->expects(
139 $this->returnValue($this->_captcha)
141 $this->_messageManager->expects($this->once())->method(
'addError')->with($warningMessage);
142 $this->_actionFlag->expects(
148 \
Magento\Framework\
App\Action\Action::FLAG_NO_DISPATCH,
152 $this->checkForgotpasswordObserver->execute(
testCheckForgotpasswordRedirects()
$checkForgotpasswordObserver