Ejemplo n.º 1
0
 public function indexAction()
 {
     /** @var \Zend\Http\Request $request */
     $request = $this->getRequest();
     try {
         if ($request->isPost()) {
             $this->form->setData($request->getPost()->toArray() ?: array());
             if ($this->form->isValid()) {
                 $mailer = $this->getPluginManager()->get('Mailer');
                 $url = $this->plugin('url');
                 $this->service->proceed($this->form->getInputFilter(), $mailer, $url);
                 $this->notification()->success('Mail with link for reset password has been sent, please try to check your email box');
             } else {
                 $this->notification()->danger('Please fill form correctly');
             }
         }
     } catch (Exception\UserNotFoundException $e) {
         $this->notification()->danger('User cannot be found for specified username or email');
     } catch (Exception\UserDoesNotHaveAnEmailException $e) {
         $this->notification()->danger('Found user does not have an email');
     } catch (\Exception $e) {
         $this->logger->crit($e);
         $this->notification()->danger('An unexpected error has occurred, please contact your system administrator');
     }
     return array('form' => $this->form);
 }
Ejemplo n.º 2
0
 public function testProceed_WhenUserDoesNotHaveAnEmail()
 {
     $identity = uniqid('identity');
     $user = UserEntityProvider::createEntityWithRandomData(array('email' => null));
     $this->inputFilterMock->expects($this->once())->method('isValid')->willReturn(true);
     $this->inputFilterMock->expects($this->once())->method('getValue')->with('identity')->willReturn($identity);
     $this->userRepositoryMock->expects($this->once())->method('findByLoginOrEmail')->with($identity)->willReturn($user);
     $this->setExpectedException('Auth\\Service\\Exception\\UserDoesNotHaveAnEmailException', 'User does not have an email');
     $this->testedObject->proceed($this->inputFilterMock, $this->mailerPluginMock, $this->urlPluginMock);
 }
Ejemplo n.º 3
0
 public function testProceed()
 {
     $name = uniqid('name') . ' ' . uniqid('surname');
     $email = uniqid('email') . '@' . uniqid('host') . '.com.pl';
     $user = UserEntityProvider::createEntityWithRandomData();
     $confirmationLink = uniqid('confirmationLink');
     $self = $this;
     $this->inputFilterMock->expects($this->once())->method('isValid')->willReturn(true);
     $this->inputFilterMock->expects($this->once())->method('get')->with('register')->willReturnSelf();
     $this->inputFilterMock->expects($this->exactly(2))->method('getValue')->willReturnOnConsecutiveCalls($name, $email);
     $this->userRepositoryMock->expects($this->once())->method('findByLoginOrEmail')->with($email)->willReturn(null);
     $user->setLogin($email)->setRole(User::ROLE_RECRUITER);
     $this->userRepositoryMock->expects($this->once())->method('create')->with(array('login' => $email, 'role' => User::ROLE_RECRUITER))->willReturn($user);
     $this->userRepositoryMock->expects($this->once())->method('store')->with($this->callback(function ($user) use($self) {
         $self->assertInstanceOf('Auth\\Entity\\User', $user);
         return $user;
     }));
     $this->urlPluginMock->expects($this->once())->method('fromRoute')->with('lang/register-confirmation', array('userId' => $user->getId()), array('force_canonical' => true))->willReturn($confirmationLink);
     $this->mailServiceMock->expects($this->once())->method('get')->with('htmltemplate')->willReturn($this->mailMock);
     $this->testedObject->proceed($this->inputFilterMock, $this->mailerPluginMock, $this->urlPluginMock);
 }