74 $this->session = $this->getMockBuilder(\
Magento\Customer\Model\Session::class)
75 ->disableOriginalConstructor()
78 $this->accountManagement = $this->getMockBuilder(\
Magento\Customer\Api\AccountManagementInterface::class)
79 ->getMockForAbstractClass();
81 $this->escaper = $this->getMockBuilder(\
Magento\Framework\Escaper::class)
82 ->disableOriginalConstructor()
88 $this->accountManagement,
95 $this->request->expects($this->once())
100 $this->messageManager->expects($this->once())
101 ->method(
'addErrorMessage')
102 ->with(
__(
'Please enter your email.'))
105 $this->resultRedirect->expects($this->once())
107 ->with(
'*/*/forgotpassword')
110 $this->assertSame($this->resultRedirect, $this->controller->execute());
117 $this->request->expects($this->once())
122 $this->accountManagement->expects($this->once())
123 ->method(
'initiatePasswordReset')
127 $this->escaper->expects($this->once())
128 ->method(
'escapeHtml')
133 'If there is an account associated with %1 you will receive an email with a link to reset your password.',
136 $this->messageManager->expects($this->once())
137 ->method(
'addSuccessMessage')
141 $this->resultRedirect->expects($this->once())
146 $this->controller->execute();
153 $this->request->expects($this->once())
158 $this->accountManagement->expects($this->once())
159 ->method(
'initiatePasswordReset')
163 $this->escaper->expects($this->once())
164 ->method(
'escapeHtml')
169 'If there is an account associated with %1 you will receive an email with a link to reset your password.',
172 $this->messageManager->expects($this->once())
173 ->method(
'addSuccessMessage')
177 $this->resultRedirect->expects($this->once())
182 $this->controller->execute();
188 $exception = new \Exception(
__(
'Exception'));
190 $this->request->expects($this->once())
195 $this->accountManagement->expects($this->once())
196 ->method(
'initiatePasswordReset')
198 ->willThrowException($exception);
200 $this->messageManager->expects($this->once())
201 ->method(
'addExceptionMessage')
202 ->with($exception,
__(
'We\'re unable to send the password reset email.'))
205 $this->resultRedirect->expects($this->once())
207 ->with(
'*/*/forgotpassword')
210 $this->controller->execute();
215 $this->resultRedirect = $this->getMockBuilder(\
Magento\Framework\Controller\Result\Redirect::class)
216 ->disableOriginalConstructor()
219 $this->resultRedirectFactory = $this->getMockBuilder(
220 \
Magento\Framework\Controller\Result\RedirectFactory::class
222 ->disableOriginalConstructor()
225 $this->context = $this->getMockBuilder(\
Magento\Framework\
App\Action\Context::class)
226 ->disableOriginalConstructor()
229 $this->request = $this->getMockBuilder(\
Magento\Framework\
App\Request\Http::class)
230 ->disableOriginalConstructor()
236 $this->messageManager = $this->getMockBuilder(\
Magento\Framework\Message\ManagerInterface::class)
237 ->getMockForAbstractClass();
239 $this->resultRedirectFactory->expects($this->any())
241 ->willReturn($this->resultRedirect);
243 $this->context->expects($this->any())
244 ->method(
'getResultRedirectFactory')
245 ->willReturn($this->resultRedirectFactory);
247 $this->context->expects($this->any())
248 ->method(
'getRequest')
249 ->willReturn($this->request);
251 $this->context->expects($this->any())
252 ->method(
'getMessageManager')
253 ->willReturn($this->messageManager);
testExecuteNoSuchEntityException()