public function testResetsPassword()
 {
     $page = $this->getMock('IPasswordPage');
     $userRepo = $this->getMock('IUserRepository');
     $encryption = $this->getMock('PasswordEncryption');
     $user = $this->getMock('User');
     $newPassword = '******';
     $encryptedValue = 'enc';
     $salt = 'salt';
     $encryptedPassword = new EncryptedPassword($encryptedValue, $salt);
     $presenter = new PasswordPresenter($page, $userRepo, $encryption);
     $page->expects($this->once())->method('ResettingPassword')->will($this->returnValue(true));
     $page->expects($this->once())->method('IsValid')->will($this->returnValue(true));
     $page->expects($this->atLeastOnce())->method('GetPassword')->will($this->returnValue($newPassword));
     $userRepo->expects($this->atLeastOnce())->method('LoadById')->with($this->equalTo($this->fakeUser->UserId))->will($this->returnValue($user));
     $encryption->expects($this->once())->method('EncryptPassword')->with($this->equalTo($newPassword))->will($this->returnValue($encryptedPassword));
     $user->expects($this->once())->method('ChangePassword')->with($this->equalTo($encryptedValue), $this->equalTo($salt));
     $userRepo->expects($this->once())->method('Update')->with($this->equalTo($user));
     $page->expects($this->once())->method('ShowResetPasswordSuccess')->will($this->returnValue(true));
     $presenter->PageLoad();
 }
Esempio n. 2
0
 public function PageLoad()
 {
     $this->presenter->PageLoad();
     $this->Display('password.tpl');
 }