Example #1
0
 public function testResetPasswordActionWithInvalidFormData()
 {
     // Preparation
     $user = UserService::findOneByUsername('testuser');
     $this->dispatch('/user/lostpassword');
     $this->getRequest()->setMethod('POST')->setPost(array('username' => $user->getUsername()));
     $this->redispatch('/user/lostpassword', false);
     $this->assertRedirectTo('/home', 'Failed to redirect');
     $resetToken = UserPasswordResetTokenService::findOneByUser($user->getId());
     $this->assertTrue(null !== $resetToken);
     // Test
     $this->redispatch('/user/resetpassword?token=' . $resetToken->getToken());
     $this->assertNotRedirect();
     $this->assertQuery('form#userPasswordResetForm');
     $this->getRequest()->setMethod('POST')->setPost(array('csrf' => $this->_getFormCsrf(), 'password' => '123', 'passwordConfirm' => '123'));
     $this->redispatch('/user/resetpassword?token=' . $resetToken->getToken(), false);
     $this->assertNotRedirect();
     $this->assertQuery('form#userPasswordResetForm');
     $this->assertTrue(UserService::verifyPassword($user, 'testuser'));
 }